获取当前时间的上月月份,格式:YYYY-MM-DD

    技术2022-07-11  99

    /** * 获取当前时间的上月月份,格式:YYYY-MM-DD * */ public static String getMonth(){ LocalDate now=LocalDate.now(); int month=now.getMonthValue(); int lastmonth=month==1?12:month-1; int year=month==1?now.getYear()-1:now.getYear(); LocalDate last=now.withYear(year); last=last.withMonth(lastmonth); return last.toString(); }
    Processed: 0.010, SQL: 10