Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static long getTwoDay(String sj1, String sj2) { SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); long day = 0; try { java.util.Date date = myFormatter.parse(sj1); java.util.Date mydate = myFormatter.parse(sj2); day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000); } catch (Exception e) { return 0; } return day; } }