We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb2d38a commit dc4a84aCopy full SHA for dc4a84a
1 file changed
datetime/JavaParseDateTime.java
@@ -0,0 +1,24 @@
1
+package com.zetcode;
2
+
3
+import java.time.LocalDate;
4
+import java.time.LocalDateTime;
5
+import java.time.format.DateTimeFormatter;
6
7
+public class JavaParseDateTime {
8
9
+ public static void main(String[] args) {
10
11
+ String sd1 = "2018-01-04";
12
+ LocalDate ld1 = LocalDate.parse(sd1);
13
+ System.out.println("Date: " + ld1);
14
15
+ String sdatetime = "2017-08-16T16:34:10";
16
+ LocalDateTime ldt = LocalDateTime.parse(sdatetime);
17
+ System.out.println("Datetime: " + ldt);
18
19
+ DateTimeFormatter dtfmt = DateTimeFormatter.ofPattern("dd MMM uuuu");
20
+ String anotherDate = "14 Aug 2017";
21
+ LocalDate lds = LocalDate.parse(anotherDate, dtfmt);
22
+ System.out.println(anotherDate + " parses to " + lds);
23
+ }
24
+}
0 commit comments