Here you can find the source of getTwoDay(String sj1, String sj2)
public static String getTwoDay(String sj1, String sj2)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String getTwoDay(String sj1, String sj2) { SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); long day = 0; try {/*from w w w .j a va2 s. c o m*/ Date date = myFormatter.parse(sj1); Date mydate = myFormatter.parse(sj2); day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000); } catch (Exception e) { return ""; } return day + ""; } public static String getTime() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime); String min; min = dateString.substring(14, 16); return min; } }