Date object deprecations in Java 1.5 migrating to Calendar object

walshcj's Avatar


28 Oct, 2010 03:39 PM

Will Cascade server be providing access to the Calendar object if there is a move to Java 1.6? Our site is currently using Date object methods to reformat dates, and we're beginning to notice a lot of the methods available in the Date object. Our main concern is still have access to these methods, that have mograted to the Calendar object as of Java 1.5

  1. 1 Posted by Brent Arrington on 28 Oct, 2010 07:18 PM

    Brent Arrington's Avatar

    You can access an instance of a Calendar object in either Java 1.5 or 1.6 in Cascade currently, via $_DateTool.getCalendar(). This will return a Calendar instance preset with the current system date/time. You may then use any of the Calendar get/set/add/etc methods.

    One note, however: I know of no way to access the static constant values in Calendar (if anyone out there has managed this, please let me know). So, this code will not work:

        #set ( $calendar = $_DateTool.getCalendar() ) 
        ## this will not work
        ## nor will this -- in fact, this will not compile
        #set ( $nextMonth = $calendar.getTime() ) 
        Next Month = ${nextMonth}<br/>

    However, the following will work:

        #set ( $calendar = $_DateTool.getCalendar() ) 
        ## this WILL work -- 2 is the literal value for java.util.Calendar.MONTH
        #set ( $nextMonth = $calendar.getTime() ) 
        Next Month = ${nextMonth}<br/>

    You can find a list of all the constant values for Calendar here

  2. 2 Posted by Brent Arrington on 28 Oct, 2010 07:22 PM

    Brent Arrington's Avatar

    Oh, incidentally, I was assuming you meant accessing Calendar from Velocity formats in Cascade... Upon a second reading, I can see that might not be what you were asking...

  3. 3 Posted by walshcj on 02 Nov, 2010 09:37 PM

    walshcj's Avatar

    No, that is exactly what I was looking for, thank you.

  4. Tim closed this discussion on 04 Nov, 2010 04:45 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM