Skip to content

Commit a8fa462

Browse files
committed
Add datetimeformatter example
1 parent af649f5 commit a8fa462

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Link to the PlayList: https://www.youtube.com/watch?v=uhPLWdvrF9g&list=PLB1G
4747
40. [Calculate Difference Between Two Dates Using Java 8 ChronoUnit](https://youtu.be/m8qP0ZyhMYo)
4848
41. [Instant Class In Java 8 Date And Time API](https://youtu.be/7k-YYH4yUxQ)
4949
42. [ZonedDateTime Class In Java 8 Date And Time API](https://youtu.be/OgZYxNiwm2Y)
50-
50+
43. [How To Format LocalDateTime In Java 8?](https://youtu.be/QMvKaHbvYwM)
5151

5252
## [Chick here to Subscribe our YouTube Channel](https://www.youtube.com/channel/UCl31HHUdQbSHOQfc9L-wo3w?sub_confirmation=1)
5353

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.coderolls.java.date_and_time.datetimeformatter;
2+
3+
import java.time.LocalDateTime;
4+
import java.time.format.DateTimeFormatter;
5+
6+
public class DateTimeFormatterExample {
7+
8+
public static void main(String[] args) {
9+
10+
LocalDateTime dt = LocalDateTime.now();
11+
System.out.println(dt);
12+
System.out.println();
13+
DateTimeFormatter formatter = DateTimeFormatter
14+
.ofPattern("dd/MM/yyyy HH:mm:ss");
15+
16+
String dtFormatted = formatter.format(dt);
17+
System.out.println(dtFormatted);
18+
19+
20+
}
21+
22+
}

0 commit comments

Comments
 (0)