[Solved] how to convert string into date? JAVA


Using SimpleDateFormatter you can convert from date string to date and date to date String

public final class DateUtil {

    private static final String DEFAULT_DATE_FORMAT = "dd-MMM-yyyy";

    private DateUtil() {
    }

    public static final String formatDate(final Date date, final String dateFormat) {
        DateFormat format = new SimpleDateFormat(dateFormat, Locale.ENGLISH);
        return format.format(date);
    }

    public static final Date formatDate(final String date) throws ParseException {
        return formatDate(date, DEFAULT_DATE_FORMAT);
    }

    public static final Date formatDate(final String date, final String dateFormat) throws ParseException {
        DateFormat format = new SimpleDateFormat(dateFormat);
        return format.parse(date);
    }
}

Whenever you are going yo format date please verify the format you are using
In your case you used dd/MM/yyyy but date you used in format dd-MMM-yyyy.

0

solved how to convert string into date? JAVA