Search code examples
grailsgroovytimestamp-with-timezone

Add 1Hour to java.sql.timeStamp in gsp or groovy


I convert new Date() to GMT. Now I need to add 1 hour to GMT time. The class is java.sql.timeStamp. How do I add 1 hour to the nowGMT variable in grails. I have magic number plugin installed in my project.

Thanks!


Solution

  • Have you tried:

    import groovy.time.TimeCategory
    
    ...
    
    Timestamp plusOne = use( TimeCategory ) { nowGMT + 1.hour }.toTimestamp()