Created
June 3, 2016 21:02
-
-
Save lorenzoongithub/127278b6478e9b35e3fca13b566f88b5 to your computer and use it in GitHub Desktop.
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
// | |
// An example of java 8 new Date/Time API. | |
// | |
var LocalDate = Java.type('java.time.LocalDate'); | |
var Month = Java.type('java.time.Month'); | |
var ChronoUnit = Java.type('java.time.temporal.ChronoUnit'); | |
var today = LocalDate.now(); | |
var firstDayThisYear = LocalDate.of(today.getYear(), Month.JANUARY, 1); | |
var days = ChronoUnit.DAYS.between(firstDayThisYear, today); | |
days + " days have passed since the beginning of the year." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment