Skip to content

Instantly share code, notes, and snippets.

@cloudqq
Created January 14, 2014 14:37
Show Gist options
  • Save cloudqq/8419244 to your computer and use it in GitHub Desktop.
Save cloudqq/8419244 to your computer and use it in GitHub Desktop.
How to parse date time format, the key is use locale.
String s = "22/Oct/2014:12:24:44 +0800";
//SimpleDateFormat p1 = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z");
// Date d1 = p1.parse(s);
SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z", new Locale("en","US"));
System.out.println(formatter.format(new Date()));
Date d1 = formatter.parse(s);
SimpleDateFormat f2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
System.out.println(f2.format(d1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment