Java Day getLastDay(Date date)

Here you can find the source of getLastDay(Date date)

Description

get Last Day

License

Apache License

Declaration

public static Date getLastDay(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getLastDay(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);/*ww  w. j  a  v  a 2  s  . c o m*/
        int value = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        cal.set(Calendar.DAY_OF_MONTH, value);
        return cal.getTime();
    }

    public static String getTime(Date date) {
        SimpleDateFormat formatter_f = new SimpleDateFormat("yyyy-MM-dd");
        String str = formatter_f.format(date);
        return str;
    }

    public static String format(Date aTs_Datetime) {
        return format(aTs_Datetime, "yyyy-MM-dd");
    }

    public static String format(Date aTs_Datetime, String as_Pattern) {
        if (aTs_Datetime == null || as_Pattern == null)
            return null;

        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Pattern);

        return dateFromat.format(aTs_Datetime);
    }
}

Related

  1. getDayStringOfDate(Date date)
  2. getDayText(Date day)
  3. getDayTime_End()
  4. getLastDay()
  5. getLastDay(Date date)
  6. getLastDay(Date date)
  7. getLastDay(String nowdate, String inFormat, String outFormat)
  8. getLastDayOfQuarter(Date date)
  9. getLastNDays(int aInN)