package com.ruoyi.cai.util;


import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

public class CaiDateUtil {


    public static LocalDate getLastWeekOne(LocalDate date){
        return date.plusWeeks(-1)
                .with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
    }

    public static String localDateTimeToString(LocalDateTime localDateTime){
        return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public static void main(String[] args) {
        LocalDate one = getLastWeekOne(LocalDate.now());
        System.out.println(one.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
    }

    public static String getCurrentTimeStr() {
        return localDateTimeToString(LocalDateTime.now());

    }
}
