-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainDate.java
More file actions
34 lines (28 loc) · 1.13 KB
/
MainDate.java
File metadata and controls
34 lines (28 loc) · 1.13 KB
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
32
33
package webapp;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class MainDate {
public static void main(String[] args) {
long start = System.currentTimeMillis();
Date date = new Date();
System.out.println(date);
System.out.println(System.currentTimeMillis() - start);
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
System.out.println(cal.getTime());
LocalDate ld = LocalDate.now();
LocalTime lt = LocalTime.now();
LocalDateTime ldt = LocalDateTime.of(ld, lt);
System.out.println(ldt);
SimpleDateFormat sdf = new SimpleDateFormat("YY/MM/dd");
System.out.println(sdf.format(date));
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/YY/dd");
System.out.println(dtf.format(ldt));
}
}