package com.gblfy.util;import org.junit.Test;
import org.springframework.stereotype.Component;import java.text.SimpleDateFormat;
import java.util.Date;@Component
public class DateDeal {//日期格式化static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");/*** 获取昨天日期** @return*/public static String getYesterday() {Date today = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);return simpleDateFormat.format(today);}/*** 获取今天日期** @return*/public static String getToday() {Date today = new Date(System.currentTimeMillis());return simpleDateFormat.format(today);}@Testpublic void gettoday() {// 2021-10-15System.out.println(DateDeal.getToday());// 2021-10-14System.out.println(DateDeal.getYesterday());}
}