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
Solved! Go to Solution.
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.
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.
Thank you very much.