package cn.wisenergy.service.Manager; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; import java.util.Date; /** * @author 86187 * @ Description: 账户管理公共类 * @ Author : 86187 * @ Date : 2021/2/23 10:43 */ @Component @Slf4j public class PublicManager { public boolean isThisMonth(Date time, String pattern) { Date date = new Date(time.getTime()); SimpleDateFormat sdf = new SimpleDateFormat(pattern); //参数时间 String param = sdf.format(date); //当前时间 String now = sdf.format(new Date()); if (param.equals(now)) { return true; } return false; } }