Posted By

callmeblessed on 01/02/09


time date groovy grails jodatime

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Groovy: Date[2] - Jodatime

 / Published in: Groovy


another way to set / create a date using jodatime download jodatime at

  1. import org.joda.time.DateTime;
  3. new DateTime().withDayOfMonth(4).withMonthOfYear(7).withYear(1776).println('EEE, 'dd/MM/yyyy HH:mm:ss');

Report this snippet  


RSS Icon Subscribe to comments
Posted By: yawmark on January 23, 2009


Not sure what that's supposed to demonstrate, but you can easily set/create a date like:

d = new DateTime('1776-07-04')

If you want it formatted:

import org.joda.time.* import org.joda.time.format.* d = new DateTime('1776-07-04') assert 'Thu, 04/07/1776 00:00:00' == DateTimeFormat.forPattern('EEE, dd/MM/yyyy HH:mm:ss').print(d)

Posted By: nightingale2k1 on August 12, 2009

it didnt work yawmark.

I did this [code] import org.joda.time.* ;

def myDate = new DateTime(new Date().parse("dd/MM/yyyy","20/10/2009")); [/code]

You need to login to post a comment.