-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDate.java
31 lines (21 loc) · 870 Bytes
/
Date.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.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class Date {
public static void main(String[] args) {
// LocalDate obj = LocalDate.now();
// System.out.println(obj);
// LocalDate d = LocalDate.now();
// LocalTime t= LocalTime.now();
// LocalDateTime ti =LocalDateTime.now();
// System.out.println("date=" +d);
// System.out.println("Time =" +t);
// System.out.println("Date &Time =" +ti);
LocalDateTime dt =LocalDateTime.now();
System.out.println("Before formatting =" +dt);
DateTimeFormatter f =DateTimeFormatter.ofPattern("dd-MM-yy HH:mm:ss");
String formattedDate = dt.format(f);
System.out.println("After Formatting=" +formattedDate);
}
}