In java,
Unable to parse date-Strings of this format Sun Apr 10 21:26:54 +05:30 2022
.
I am using java.text.SimpleDateFormat
to parse this String.
The pattern that i'm using : E MMM dd hh:mm:ss X yyyy
I'm mainly unable to work if the timezone (+05:30) is present before the year-value.
X
seems to work only if it is at the end of the String.
I have tried Z
, but it doesn't work.
Sample code :
String dateStr = "Sun Apr 10 21:26:54 +05:30 2022";
java.util.Date epoch = new java.text.SimpleDateFormat("E MMM dd hh:mm:ss X yyyy")
.parse(dateStr);
Error im getting :
Exception in thread "main" java.text.ParseException: Unparseable date: "Sun Apr 10 21:26:54 +05:30 2022"
at java.text.DateFormat.parse(DateFormat.java:366)
at com.company.ExifDataExtractor.main(ExifDataExtractor.java:51)