Skip to content

Instantly share code, notes, and snippets.

@metalefty
Last active August 29, 2015 14:00
Show Gist options
  • Save metalefty/1e4df013ce8677e4376e to your computer and use it in GitHub Desktop.
Save metalefty/1e4df013ce8677e4376e to your computer and use it in GitHub Desktop.
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