自动化立体仓库 - WMS系统
#
zjj
2025-09-17 4474cf3c30e6ad06711d2021be15ff82c36bd75a
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.zy.kingdee.utils;
 
import com.alibaba.excel.util.StringUtils;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
 
public class ERPDateUtil {
    public static int getDiffBetweenMonths(Date date1, Date date2) {
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        c1.setTime(date1);
        c2.setTime(date2);
        int result = c2.get(2) - c1.get(2);
        int month = (c2.get(1) - c1.get(1)) * 12;
        return Math.abs(result + month);
    }
 
    public static Date getNextMonthDate(Date date, int afterMonth) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(2, calendar.get(2) + afterMonth);
        Date next = calendar.getTime();
        return next;
    }
 
    public static Date getFirstDate(String string) throws ParseException {
        if (StringUtils.isEmpty(string)) {
            return null;
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date date = simpleDateFormat.parse(string + "-01 00:00:00");
        return date;
    }
 
    public static String getNextDateStr(Date date, int afterDay) {
        Date nextDate = getNextDate(date, afterDay);
        String dateStr = getDateStr(nextDate, "yyyy-MM-dd");
        return dateStr;
    }
 
    public static Date getNextDate(Date date, int afterDay) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        Integer day = Integer.valueOf(calendar.get(5));
        calendar.set(5, day.intValue() + afterDay);
        Date newDate = calendar.getTime();
        return newDate;
    }
 
    public static String getDateStr(Date date, String format) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        String s = simpleDateFormat.format(date);
        return s;
    }
 
    public static Date parseStrToDate(String string, String format) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        Date parse = simpleDateFormat.parse(string);
        return parse;
    }
 
    public static int getMonth(String string) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse(string);
        int month = parse.getMonth() + 1;
        return month;
    }
 
    public static void main(String[] args) throws ParseException {
        Date a = getFirstDate("2018-8");
        System.out.print(a);
    }
 
}