This file contains 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 characters
<select class="custom-select form-control" id="exp-year"> | |
<option value="2019">2019</option> | |
<option value="2020">2020</option> | |
<option value="2020">2021</option> | |
<option value="2020">2022</option> | |
<option value="2023">2023</option> | |
</select> |
This file contains 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 characters
jshell> LocalTime lt1 = LocalTime.now(); | |
lt1 ==> 21:22:05.322393 | |
jshell> LocalTime lt2 = LocalTime.parse("12:00"); | |
lt2 ==> 12:00 | |
jshell> LocalTime lt3 = LocalTime.of(12, 0); // Hour, minutes | |
lt3 ==> 12:00 | |
jshell> LocalTime lt4 = LocalTime.of(12, 0, 1); // Hour, minutes, seconds |
This file contains 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 characters
jshell> LocalDate ld1 = LocalDate.now(); | |
ld1 ==> 2019-04-23 | |
jshell> LocalDate ld2 = LocalDate.parse("2019-01-01"); // Date | |
ld2 ==> 2019-01-01 | |
jshell> LocalDate ld3 = LocalDate.of(2019, 1, 1); // Year, Month, Day | |
ld3 ==> 2019-01-01 | |
jshell> LocalDate ld4 = LocalDate.of(2019, Month.JANUARY, 1); // Year, Month, Day |
This file contains 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 characters
jshell> LocalDateTime ldt1 = LocalDateTime.now(); | |
ldt1 ==> 2019-04-23T21:41:59.084165 | |
jshell> LocalDateTime ldt2 = LocalDateTime.parse("2019-01-01T12:00:00"); | |
ldt2 ==> 2019-01-01T12:00 | |
jshell> LocalDateTime ldt3 = LocalDateTime.of(2019, 1, 1, 12, 0); | |
ldt3 ==> 2019-01-01T12:00 | |
jshell> LocalDateTime ldt4 = LocalDateTime.of(2019, Month.JANUARY, 1, 12, 0); |
This file contains 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 characters
jshell> import java.util.Calendar; | |
jshell> import java.time.Instant; | |
jshell> Calendar calendar = Calendar.getInstance(); | |
calendar ==> java.util.GregorianCalendar[time=1556074159985,ar ... 600000,DST_OFFSET=3600000] | |
jshell> Instant instant = calendar.toInstant(); | |
instant ==> 2019-04-24T02:49:19.985Z |
This file contains 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 characters
jshell> LocalDate ld = LocalDate.now(); | |
ld ==> 2019-04-23 | |
jshell> // All plus methods | |
jshell> ld = ld.plusYears(1).plusMonths(12).plusWeeks(52).plusDays(365); | |
ld ==> 2023-04-22 | |
jshell> // All minus methods |
This file contains 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 characters
jshell> Period P1 = Period.ofYears(1); // 1 year | |
P1 ==> P1Y | |
jshell> Period P2 = Period.ofMonths(12) // 1 year | |
P2 ==> P12M | |
jshell> Period P3 = Period.ofWeeks(52) // 1 year | |
P3 ==> P364D | |
jshell> Period P4 = Period.ofDays(366) // 1 year (leap) |
This file contains 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 characters
jshell> Period period = Period.of(5, 2, 1); | |
period ==> P5Y2M1D | |
jshell> period = period.plusYears(10); | |
period ==> P15Y2M1D | |
jshell> period = period.plusMonths(10); | |
period ==> P15Y12M1D | |
jshell> period = period.plusDays(15); |
This file contains 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 characters
jshell> Period p1 = Period.parse("P10D").minusDays(10); | |
p1 ==> P0D | |
jshell> "Is zero: " + p1.isZero(); | |
$24 ==> "Is zero: true" | |
jshell> // Period equals negative value | |
jshell> Period p2 = Period.parse("P2019M"); | |
p2 ==> P2019M |
This file contains 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 characters
shell> String WAR_OF_1812_START_DATE = "1812-06-18"; | |
WAR_OF_1812_START_DATE ==> "1812-06-18" | |
jshell> String WAR_OF_1812_END_DATE = "1815-02-18"; | |
WAR_OF_1812_END_DATE ==> "1815-02-18" | |
jshell> import java.time.LocalDate; | |
jshell> LocalDate warBegins = LocalDate.parse(WAR_OF_1812_START_DATE); | |
warBegins ==> 1812-06-18 |