Java Day End getEndOfDay(Date when)

Here you can find the source of getEndOfDay(Date when)

Description

get End Of Day

License

Apache License

Declaration

public static Date getEndOfDay(Date when) 

Method Source Code

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

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getEndOfDay(Date when) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(getStartOfDay(when));
        cal.add(Calendar.DATE, 1);
        cal.add(Calendar.SECOND, -1);
        return cal.getTime();
    }/* ww  w .  ja v  a  2 s  .c o m*/

    public static Date getStartOfDay(Date when) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(when);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        return cal.getTime();
    }
}

Related

  1. getEndOfDay(Date date)
  2. getEndOfDay(Date date)
  3. getEndOfDay(Date date)
  4. getEndOfDay(Date day)
  5. getEndOfDay(Date day)
  6. getEndOfDay(final Date date, final TimeZone timeZone)
  7. getEndOfDay(Long date)
  8. getEndOfHour(Date day)
  9. getEndOfTheDate(Date date)