Last active
August 29, 2015 14:00
-
-
Save metalefty/1e4df013ce8677e4376e to your computer and use it in GitHub Desktop.
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
package simpledateformatsample; | |
import java.text.DateFormat; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
public class SimpleDateFormatSample { | |
public static void main(String[] args) throws ParseException { | |
String dateString = "2014/12/28"; | |
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/dd"); | |
Date date = DateFormat.getDateInstance().parse(dateString); | |
System.out.printf("%s = %s = %s\n", sdf.format(date), dateString, date.toString()); | |
// => 2015/12/28 = 2014/12/28 = Sun Dec 28 00:00:00 JST 2014 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment