Forum Discussion
2 Replies
- SiKingCommunity HeroAre you asking for a weekend date, or are you asking for an invalid date?
For an invalid date just place another digit at the end, so something like${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date())}1
For a weekend date this is not going to be a one-liner! You will probably have to use GregorianCalendar(); see http://groovy.codehaus.org/JN0545-Dates for hints. - Here's some Groovy code which will store the next Saturday or Sunday in the variable nonWorkingDay:
def calendar = Calendar.getInstance()
def dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK)
def offset = Calendar.SATURDAY - dayOfWeek
if (offset > 0) calendar.add(Calendar.DAY_OF_WEEK, offset )
def nonWorkingDay = calendar.time