Java examples for java.util:Day
get Interval Days
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { String startDate = "java2s.com"; String endDate = "java2s.com"; System.out.println(getIntervalDays(startDate, endDate)); }/*from w ww .ja va2 s . c o m*/ public static Long getIntervalDays(String startDate, String endDate) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date beginTime = sdf.parse(startDate); Date endTime = sdf.parse(endDate); long interval = (endTime.getTime() - beginTime.getTime()) / 1000;// ? long day = interval / (24 * 3600);// ? return day; } catch (Exception e) { } return 0l; } }