fork(2) download
  1. import java.text.SimpleDateFormat;
  2. import java.util.Date;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String str = "2019-05-24T00:59:55.1-05:00";
  9.  
  10. // Remove the colon in the timezone indicator
  11. // Not sure when Java got assert, so commenting this out: assert str.charAt(str.length() - 3) == ':';
  12. str = str.substring(0, str.length() - 3) + str.substring(str.length() - 2);
  13. // Parse the result
  14. Date dt = (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")).parse(str);
  15. System.out.println(dt.toString());
  16. }
  17. }
Success #stdin #stdout 0.07s 2184192KB
stdin
Standard input is empty
stdout
Fri May 24 05:59:55 GMT 2019