java获取本月开始的一天与最后一天

/**
     * 获取本月第一天
     * @return
     */
    public  Date getmindate(){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
        
        return calendar.getTime();
    }

    /**
     * 获取本月最后一天
     * @return
     */
    public  Date getmaxdate(){
        Calendar calendar2 = Calendar.getInstance();
        calendar2.setTime(new Date());
        calendar2.set(Calendar.DAY_OF_MONTH, calendar2.getActualMaximum(Calendar.DAY_OF_MONTH));
        return calendar2.getTime();
    }

 

posted @ 2020-06-18 15:14  想当胖子  阅读(191)  评论(0编辑  收藏  举报

载入天数...载入时分秒...