How to make Date format in Java, 자바 SimpleDateFormat 연월일/날짜 형식, time, 시분초, basic grammar
Sameple code
public void dateFormatTest() {
String dateFormat = "yyyyMMddHHmmss";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
String dateString = simpleDateFormat.format(new Date());
System.out.println(dateString);
}
You can use various dateFormat string to print different format using diff string format like examples below.
아래와 같이 dateFormat 문자를 바꿔서 다양하게 출력할 수 있다.
DataFormat Examples
dd-MM-yy 31-01-12
dd-MM-yyyy 31-01-2012
MM-dd-yyyy 01-31-2012
yyyy-MM-dd 2012-01-31
yyyy-MM-dd HH:mm:ss 2012-01-31 23:59:59
yyyy-MM-dd HH:mm:ss.SSS 2012-01-31 23:59:59.999
yyyy-MM-dd HH:mm:ss.SSSZ 2012-01-31 23:59:59.999+0100
EEEEE MMMMM yyyy HH:mm:ss.SSSZ Saturday November 2012 10:45:42.720+0100