"timestamp_utc": "۲۰۱۵-۱۱-۰۲T۱۸:۴۴:۳۴+۰۰:۰۰"
is an attribute in a JSON. How do I parse this date? I tried the following piece of code.
try
{
return new DateTime(dateStr, DateTimeZone.UTC);
}
catch (IllegalArgumentException e)
{
java.util.Locale locale = new java.util.Locale( "ar", "SA" );
DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withLocale( locale );
return formatter.parseDateTime( dateStr );
}
2015-05-11T11:31:47
Works just fine. However,
۲۰۱۵-۱۱-۰۲T۱۸:۴۴:۳۴+۰۰:۰۰
throws an IllegalArgumentException
. Tried parsing the date with other locales/formats as well. No luck.
Locale list[] = DateFormat.getAvailableLocales();
for (Locale aLocale : list) {
try{
DateTimeFormatter formatter = DateTimeFormat.forPattern( "yyyy-MM-dd'T'HH:mm:ssZ" ).withLocale(aLocale);
System.out.println(formatter.parseDateTime( dateStr ));
}
catch(Exception e){
System.out.println("locale " + aLocale.toString() + " error");
}
}
Please help me out.