[Java] 判断是否为月末

import   java.util.Calendar; 
import java.text.Format;
import java.text.SimpleDateFormat

String str ="20130630"
SimpleDateFormat format= new SimpleDateFormat("yyyyMMdd"); 
Date date=format.parse(str)
boolean isData = isLastDayOfMonth(date)
log.info isData

    boolean isLastDayOfMonth(Date date) { 
        Calendar calendar = Calendar.getInstance(); 
        calendar.setTime(date); 
        calendar.set(Calendar.DATE, (calendar.get(Calendar.DATE) + 1)); 
        if (calendar.get(Calendar.DAY_OF_MONTH) == 1) { 
            return true; 
        } 
        return false; 
    } 

 

posted @ 2017-05-25 17:04  Sunshine168  阅读(3433)  评论(0编辑  收藏  举报