The date from server is coming as 2018-05-19T04:51:29.6702751+00:00
.
I need to convert this string in Date object
in Android.
I don't know how to handle the part after "+" sign
The date from server is coming as 2018-05-19T04:51:29.6702751+00:00
.
I need to convert this string in Date object
in Android.
I don't know how to handle the part after "+" sign
If you are on Java-8 you can parse the string using ZonedDateTime class something like:
ZonedDateTime d = ZonedDateTime.parse("2018-05-19T04:51:29.6702751+00:00");
Date date = Date.from(d.toInstant());
System.out.println(date.toString());
For Java-7 you can do like this:
SimpleDateFormat formatwithzone = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX");
Date date1 = formatwithzone.parse("2018-05-19T04:51:29.6702751+05:30");
System.out.println(date1.toString());