dateUtil

阅读更多
/**
* 取得上周日
*/
static def getLastSunday() {
def lastSunday
def dateFormat = new java.text.SimpleDateFormat('yyyy-MM-dd')
dateFormat.format(new Date())
Calendar calendar = dateFormat.getCalendar()
while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
    calendar.add(Calendar.DATE,-1)
}
lastSunday = dateFormat.format(calendar.getTime()).toString()
return lastSunday
}

你可能感兴趣的:(Java)