-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateEx.java
More file actions
27 lines (21 loc) · 771 Bytes
/
Copy pathDateEx.java
File metadata and controls
27 lines (21 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.javaex.api.utility.date;
import java.text.DateFormat;
import java.util.Date;
public class DateEx {
public static void main(String[] args) {
// 날짜를 얻어옴
Date now = new Date();
String nowStr = now.toString();
System.out.println(nowStr);
System.out.println(now.toLocaleString()); // deprecated
// 형식에 맞게 출력
DateFormat df = DateFormat.getDateInstance(DateFormat.FULL);
System.out.println(df.format(now));
df = DateFormat.getDateInstance(DateFormat.LONG);
System.out.println(df.format(now));
df = DateFormat.getDateInstance(DateFormat.MEDIUM);
System.out.println(df.format(now));
df = DateFormat.getDateInstance(DateFormat.SHORT);
System.out.println(df.format(now));
}
}