Answers for "new date groovy"

1

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)
Posted by: Guest on March-11-2021
0

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
Posted by: Guest on May-04-2020

Browse Popular Code Answers by Language