I am getting response string 2018-10-03T09:00:36.845+0000
and i have to parse it for PrettyTime some min ago .
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
its not working, can you tell me Dateformat string to add in SimpleDateFormat ?
Here is My code
:
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
long time = sdf.parse(device_for_bottomviews.get(i).lastupdate).getTime();
PrettyTime prettyTime = new PrettyTime(Locale.getDefault());
String ago = prettyTime.format(new Date(time));
lastupdate.setText(ago);
}
catch (Exception e)
{
e.printStackTrace();
lastupdate.setText(device_for_bottomviews.get(i).lastupdate);
}
exception i am getting
java.lang.IllegalArgumentException
at java.util.Date.parse(Date.java:633)
at java.util.Date.<init>(Date.java:272)
at com.test.busmanagement.MapActivity$DeviceAdapter.getView(MapActivity.java:721)
at android.widget.AbsListView.obtainView(AbsListView.java:2363)
at android.widget.ListView.makeAndAddView(ListView.java:1970)
at android.widget.ListView.fillDown(ListView.java:704)
at android.widget.ListView.fillFromTop(ListView.java:765)