I am working on android application where i am getting date from server like : Thu Jul 02 14:18:58 GMT+04:00 2015
and after parsing it through SimpleDateFormat i am getting it like: Thursday , July 02 , 2015 02:18 PM. And through Calender.getTime()
i am getting the time Thu Jul 02 14:57:25 GMT+04:00 2015
and after parsing it i am getting Thursday , July 02 , 2015 02:57 PM
. Now i just need to take the time difference between two date and times. I was doing like the following thing but it is giving me NumberFormat Exception. Please help me out here.
Calendar cal = Calendar.getInstance();
cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("EEEE , MMMM dd , yyyy hh:mm a");
String systemTime = sdf.format(cal.getTime());
int lastLocationSyncInt = Integer.parseInt(lastLocationSync);
int systemTimeInt = Integer.parseInt(systemTime);
int lastSeenTimeDifference = systemTimeInt -lastLocationSyncInt ;
mMap.addMarker(markerOptions).setSnippet(lastSeenTimeDifference+"");