Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // takes the date encoded as milliseconds since midnight, January 1, 1970 UTC
  2. def mydate = new Date(System.currentTimeMillis())
  3.  
  4. // create from an existing Calendar object
  5. def mydate = new GregorianCalendar(2014, Calendar.APRIL, 3, 1, 23, 45).time
  6.  
  7. // uses the format strings from Java's SimpleDateFormat
  8. def mydate = Date.parse("yyyy-MM-dd hh:mm:ss", "2014-04-03 1:23:45")
  9.  
  10. // uses a format equivalent to EEE MMM dd HH:mm:ss zzz yyyy
  11. def mydate = Date.parseToStringDate("Thu Apr 03 01:23:45 UTC 2014")
  12.  
  13. def mydate = new Date().copyWith(
  14. year: 2014,
  15. month: Calendar.APRIL,
  16. dayOfMonth: 3,
  17. hourOfDay: 1,
  18. minute: 23,
  19. second: 45)
  20.  
  21. def calendar = new GregorianCalendar(2011,1,7,15,7,23)
  22. def date = calendar.getTime()
  23. println date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement