Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // takes the date encoded as milliseconds since midnight, January 1, 1970 UTC
- def mydate = new Date(System.currentTimeMillis())
- // create from an existing Calendar object
- def mydate = new GregorianCalendar(2014, Calendar.APRIL, 3, 1, 23, 45).time
- // uses the format strings from Java's SimpleDateFormat
- def mydate = Date.parse("yyyy-MM-dd hh:mm:ss", "2014-04-03 1:23:45")
- // uses a format equivalent to EEE MMM dd HH:mm:ss zzz yyyy
- def mydate = Date.parseToStringDate("Thu Apr 03 01:23:45 UTC 2014")
- def mydate = new Date().copyWith(
- year: 2014,
- month: Calendar.APRIL,
- dayOfMonth: 3,
- hourOfDay: 1,
- minute: 23,
- second: 45)
- def calendar = new GregorianCalendar(2011,1,7,15,7,23)
- def date = calendar.getTime()
- println date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement