Search code examples
androidsimpledateformatdatetime-conversion

Convert the time stamps into long value


I would like to convert this time stamps to Long value.

2016-07-13T21:11:45+00:00

I still don't know what the format of above time stamp, like MM/dd/yyyy hh:mm:ss aa to use with the SimpleDateFormat.


Solution

  • Try this code to

       String timeStr = "2016-11-01T09:45:00.000+02:00";
       SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
       Date dateObj= sdf.parse(timeStr);
       System.out.println(dateObj.getTime());