guoshilong
2024-02-27 0bdd1bda41e6fa8436d070b1f4e5b1f19f86d9d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cn.gistack.sm.sjztmd.util;
 
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
public  class MyDateUtils {
 
    /**
     * 判断当前日期是否在汛期,汛期
     * @return
     */
    public static Boolean isTodayInFloodSeason(){
        Boolean inSeason = true;
 
        Date today = DateUtil.now();
 
        String todayStr = DateUtil.format(today, "yyyy-MM-dd");
        String nowYear = todayStr.split("-")[0];
 
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 
        try {
            Date startDate = sdf.parse(StringUtil.format("{}-05-01",nowYear));
            Date endDate = sdf.parse(StringUtil.format("{}-11-01",nowYear));
 
            inSeason = today.after(startDate)&&today.before(endDate);
            return inSeason;
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
 
 
 
}