* 두 날짜간의 차이를 구하는 함수

1
2
3
4
5
6
7
8
9
10
11
    public static long diffOfDate(String begin, String end) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        
        Date stDt = format.parse(begin);
        Date edDt = format.parse(end);
        
        long diff = edDt.getTime() - stDt.getTime();
        long diffDays = diff / (24 * 60 * 60 * 1000);
        
        return diffDays;
    }
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

* 메인 함수 예제

1
2
3
4
    public static void main(String[] argv) throws Exception {
        long ret = diffOfDate("20191023""20191104");
        System.out.println("ret : " + ret);
    }
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

+ Recent posts