"timestamp_utc": "۲۰۱۵-۱۱-۰۲T۱۸:۴۴:۳۴+۰۰:۰۰"
is an attribute in JSON. How to parse this date? I tried the following code snippet.
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 great. However, ۲۰۱۵-۱۱-۰۲T۱۸:۴۴:۳۴+۰۰:۰۰ throws an IllegalArgumentException . Tried date parsing with other locales / formats. Bad 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.
java date time jodatime arabic
Karthick r
source share