Last active
December 29, 2018 11:32
-
-
Save shady-robot/4aaffb7485a5f35aae07 to your computer and use it in GitHub Desktop.
Revisions
-
shady-robot revised this gist
Jul 5, 2015 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,6 +29,15 @@ Example: (Java 8) Use the java.time package: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); LocalDateTime dateTime = LocalDateTime.parse(str, formatter); Example: (java 8) import java.time.*; ####Problem Set Get the current date, and format it. ####Code here LocalDate date = LocalDate.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMM yyyy"); String one = date.format(formatter); System.out.println("Format Date: "+one); Example:(Use the java.text.SimpleDateFormat package) ####Problem Set -
shady-robot revised this gist
Jul 5, 2015 . 2 changed files with 19 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,3 @@ Mostly about the java.time package, about time and date format issue. Nothing Special, just for reference. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,19 +10,30 @@ z = time zone text (e.g. Pacific Standard Time...) Z = time zone, time offset (e.g. -0800) yyyy-MM-dd (2009-12-31) dd-MM-YYYY (31-12-2009) E hh:mm a (Sun 1:18 PM) E MMM yyyy (Sun Jul 2015) E MMMM yyyy (Sun July 2015) E MMMM yy (Sun July 15) EEEE MMMM yyyy (Sunday July 2015) yyyy-MM-dd HH:mm:ss (2009-12-31 23:59:59) HH:mm:ss.SSS (23:59.59.999) yyyy-MM-dd HH:mm:ss.SSS (2009-12-31 23:59:59.999) yyyy-MM-dd HH:mm:ss.SSS Z (2009-12-31 23:59:59.999 +0100) Example: (Java 8) Use the java.time package: ####Code Here String str = "1996-08-08 12:30"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); LocalDateTime dateTime = LocalDateTime.parse(str, formatter); Example:(Use the java.text.SimpleDateFormat package) ####Problem Set How to format "2015-07-01 09:00:02" date to 9:00 ####Code Here String str = "2015-07-01 09:00:02"; Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(originalString); String newString = new SimpleDateFormat(H:mm).format(date); -
shady-robot revised this gist
Jul 4, 2015 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,4 +19,10 @@ HH:mm:ss.SSS (23:59.59.999) yyyy-MM-dd HH:mm:ss.SSS (2009-12-31 23:59:59.999) yyyy-MM-dd HH:mm:ss.SSS Z (2009-12-31 23:59:59.999 +0100) Example: (Java 8) Use the java.time package: String str = "1996-08-08 12:30"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); LocalDateTime dateTime = LocalDateTime.parse(str, formatter); -
shady-robot created this gist
Jul 4, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Nothing Special, just for reference. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ y = year (yy or yyyy) M = month (MM) d = day in month (dd) h = hour (0-12) (hh) H = hour (0-23) (HH) m = minute in hour (mm) s = seconds (ss) S = milliseconds (SSS) z = time zone text (e.g. Pacific Standard Time...) Z = time zone, time offset (e.g. -0800) yyyy-MM-dd (2009-12-31) dd-MM-YYYY (31-12-2009) yyyy-MM-dd HH:mm:ss (2009-12-31 23:59:59) HH:mm:ss.SSS (23:59.59.999) yyyy-MM-dd HH:mm:ss.SSS (2009-12-31 23:59:59.999) yyyy-MM-dd HH:mm:ss.SSS Z (2009-12-31 23:59:59.999 +0100)