-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateFormatTest.java
More file actions
25 lines (17 loc) · 780 Bytes
/
DateFormatTest.java
File metadata and controls
25 lines (17 loc) · 780 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
package datereflection;
import java.text.DateFormat;
import java.util.Date;
public class DateFormatTest {
public static void main(String[] args) {
Date currentDate = new Date();
System.out.println("Date: " + currentDate);
String dateToStr = DateFormat.getInstance().format(currentDate);
System.out.println("Date: getInstance(): " + dateToStr);
dateToStr = DateFormat.getDateInstance().format(currentDate);
System.out.println("Date: getDateInstance(): " + dateToStr);
dateToStr = DateFormat.getTimeInstance().format(currentDate);
System.out.println("Date: getTimeInstance(): " + dateToStr);
dateToStr = DateFormat.getDateTimeInstance().format(currentDate);
System.out.println("Date: getDateTimeInstance(): " + dateToStr);
}
}