Groovy web console

subscribe to the feed Subscribe
to this
site

get quarter from localDate

Published 3 weeks ago by aeischeid with tags localDate
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def today = java.time.LocalDate.now()
int month = today.getMonthValue() /* 1 through 12 */
Integer quarter = ((month-1) / 3) + 1
int year = today.getYear()

println 'localDate ' + today
println 'month ' + month
println 'quarter ' + quarter