unparseable date error in java

https‮l.www//:‬autturi.com
unparseable date error in java

The error "unparseable date" in Java usually indicates that you are trying to parse a date string using the SimpleDateFormat class, but the date string is not in a format that can be recognized by the SimpleDateFormat parser.

To fix this error, you will need to ensure that the date string you are trying to parse is in a format that is supported by the SimpleDateFormat class. You can do this by specifying the correct format pattern when creating a SimpleDateFormat object.

For example, if you are trying to parse a date string in the format "yyyy-MM-dd", you would use the following code:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(dateString);

If you are unsure of the format of the date string you are trying to parse, you can use the DateFormat.getDateInstance method to get a DateFormat object that can parse a variety of common date formats. You can then use this object to parse the date string.

For example:

DateFormat df = DateFormat.getDateInstance();
Date date = df.parse(dateString);

This will try to parse the date string using a default date format for the current locale.

If you are still encountering the "unparseable date" error after ensuring that the date string is in a supported format, it is possible that there may be some other issue with the date string. For example, the date string may be missing some required components, or it may contain invalid values. In this case, you will need to examine the date string and fix any issues with its format.

Created Time:2017-10-17 22:51:25  Author:lautturi