new date groovy code example
Example 1: new date groovy
// 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
Example 2: get date now groovy
import java.text.SimpleDateFormat
import java.util.Date
Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
int yearNow = calendar.get(Calendar.YEAR)
int monthNow = calendar.get(Calendar.MONTH)
int dayNow = calendar.get(Calendar.DAY_OF_MONTH)