Java SQL Date getLastDay()

Here you can find the source of getLastDay()

Description

get Last Day

License

Apache License

Declaration

public static String getLastDay() 

Method Source Code

//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);
    }
}

Related

  1. getFirstDayOfNextMonth()
  2. getFirstDayOfThisMonth()
  3. getInsertarEmpleado()
  4. getInsertarEntrada()
  5. getIntervalDays(String sd, String ed)
  6. getMonthInt(String month)
  7. getNextDayStr(String curday)
  8. getNextDayStr(String curday)
  9. getNow()