Here you can find the source of getLastDay()
public static String getLastDay()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getLastDay() { Calendar c = Calendar.getInstance(); c.setTime(getNowDate());/*from w w w . j a v a 2s . c om*/ int today = c.get(5); c.set(5, today - 1); String lastDay = new SimpleDateFormat("yyyyMMdd").format(c.getTime()); return lastDay; } public static java.sql.Date getNowDate() { java.util.Date date = new java.util.Date(); return new java.sql.Date(date.getTime()); } public static String format(java.util.Date date) { return date == null ? "" : format(date, "yyyy-MM-dd"); } public static String format(java.util.Date date, String pattern) { return date == null ? "" : new SimpleDateFormat(pattern).format(date); } }