获取指定月份的天数

    xiaoxiao2022-07-13  154

    /** * 获取指定月份的天数 * @return */ public static Integer getDayByMoth(String source,String pattern){ Assert.notNull(source,"dateString cannot be null"); Assert.notNull(pattern,"parse date pattern cannot be null"); SimpleDateFormat simpleDate = new SimpleDateFormat(pattern); Calendar rightNow = Calendar.getInstance(); int days = 0; try { rightNow.setTime(simpleDate.parse(source)); days = rightNow.getActualMaximum(Calendar.DAY_OF_MONTH); } catch (ParseException e) { log.error("<getDayByMoth> parse date " + source + " error..{}",e); } return days; }

     

    最新回复(0)