Skip to main content
Joe_Luthy
Level 2
Oct 25, 2022 9:41 PM UTC
Solved

Velocity date incorrect month

Hi, 

I am attempting to use the Velocity date scripting to show specific event times based on the month.  Currently the actual month is October (10). But I was not getting the right output.  I modified the script to show the current date.  What displays is 2022/9/25 and the actual (current date) is 2022/10/25.  Can someone identify the issue

 

##Inserts next available class start #set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Phoenix") ) #set( $defaultLocale = $date.getLocale() ) #set( $calNow = $date.getCalendar() ) #set( $ret = $calNow.setTimeZone($defaultTimeZone) ) #set( $calConst = $field.in($calNow) ) #set( $ISO8601DateOnly = "yyyy-MM-dd" ) #set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" ) #set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" ) #set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" ) #set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) #if( $calNow.get($calConst.MONTH) != 10 ) $calNow.get($calConst.YEAR) $calNow.get($calConst.MONTH) $calNow.get($calConst.DAY_OF_MONTH) $calNow.get($calConst.DAY_OF_WEEK) #end
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Oct 25, 2022 10:29 PM UTC

Remember to use the Syntax Highlighter when posting code. (I edited your post this time.)

 

There’s not actually an issue here. Gregorian months are zero-based, so January is 0.

 

P.S. When checking inequality, you should use not-equals:

#if( !$field.equals(value) ) ## etc.

2 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Oct 25, 2022 10:29 PM UTC

Remember to use the Syntax Highlighter when posting code. (I edited your post this time.)

 

There’s not actually an issue here. Gregorian months are zero-based, so January is 0.

 

P.S. When checking inequality, you should use not-equals:

#if( !$field.equals(value) ) ## etc.
Translate
Joe_Luthy
Joe_LuthyAuthor
Level 2
Oct 25, 2022 11:50 PM UTC

Thank you very much.

Translate