Actualmente estoy usando el siguiente código para obtener el año, mes, día del mes, la hora y los minutos en Groovy:Groovy/Grails clase fecha - día del mes conseguir
Date now = new Date()
Integer year = now.year + 1900
Integer month = now.month + 1
Integer day = now.getAt(Calendar.DAY_OF_MONTH) // inconsistent!
Integer hour = now.hours
Integer minute = now.minutes
// Code that uses year, month, day, hour and minute goes here
Usando getAt(Calendar.DAY_OF_MONTH)
para el día de el mes parece un poco inconsistente en este contexto. ¿Hay alguna forma más corta de obtener el día del mes?
¿Por qué estás haciendo ahora.año + 1900? –
Mykola: new Date(). Year is currently 109, de ahí la necesidad de agregar 1900. – knorv
¿Pero por qué agrega esto a algún 'año' y no lo usa? –