-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewFormatTest7_7_1.java
31 lines (27 loc) · 1.09 KB
/
NewFormatTest7_7_1.java
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
28
29
30
31
import java.util.*;
import java.text.*;
import java.time.format.*;
import java.time.*;
public class NewFormatTest7_7_1
{
public static void main(String[] args)
{
//three kinds of datetimeFormatter to generate date,then output
//Create DTF array which includes static property, 2 local dateTF 3 selfDefine
DateTimeFormatter[] dtf = new DateTimeFormatter[]{
DateTimeFormatter.ISO_DATE,
DateTimeFormatter.ISO_TIME,
DateTimeFormatter.ISO_DATE_TIME,
//local ways, SelfDefine
DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL),
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT),
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG,FormatStyle.SHORT),
DateTimeFormatter.ofPattern("Gyyyy MMM dd a HH mm OOOO"),
};
DateTimeFormatter dateS = DateTimeFormatter.ISO_INSTANT;
//System.out.println("Me output"+dateS.toString());
LocalDateTime ldt = LocalDateTime.now();
for(int i = 0;i<dtf.length;i++) //DateTimeFormatter d:dtf)
{System.out.println(dtf[i].format(ldt));}
}
}