Created
January 14, 2014 14:37
-
-
Save cloudqq/8419244 to your computer and use it in GitHub Desktop.
How to parse date time format, the key is use locale.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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