Here you can find the source of subtractDate(Date d, long day)
public static Date subtractDate(Date d, long day)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date subtractDate(Date d, long day) { long time = d.getTime(); day = day * 24 * 60 * 60 * 1000; time -= day;//from ww w.j a va 2 s . c o m return new Date(time); } public static long getTime() { java.util.Date dt = new java.util.Date(); return dt.getTime(); } public static String getTime(String s) { if (s == null || s.equals("")) return ""; String s1 = ""; try { SimpleDateFormat simpledateformat = new SimpleDateFormat(s); s1 = simpledateformat.format(Calendar.getInstance().getTime()); } catch (Exception exception) { System.out.println(Calendar.getInstance().toString() + "cannot format time [function:getTime(String)]"); exception.printStackTrace(); } return s1; } }