Java Day End endOfDay(Date aDate)

Here you can find the source of endOfDay(Date aDate)

Description

end Of Day

License

Apache License

Declaration

public static Date endOfDay(Date aDate) 

Method Source Code

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

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

public class Main {
    private Calendar calendar;
    private static final String COLON = ":";
    private static final String ZERO = "0";

    public static Date endOfDay(Date aDate) {
        Calendar cal = GregorianCalendar.getInstance();
        cal.setTime(aDate);//from w w  w . j a v a 2s .  com
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR_OF_DAY, 24);
        Date midnight = cal.getTime();
        return midnight;
    }

    public String getTime() {
        return getHour() + COLON + getMinute();
    }

    public int getHour() {
        return calendar.get(Calendar.HOUR_OF_DAY);
    }

    public String getMinute() {
        int tempMinute = calendar.get(Calendar.MINUTE);
        return tempMinute < 10 ? ZERO + tempMinute : Integer.toString(tempMinute);
    }
}

Related

  1. dayValue(Date date, boolean startEnd)
  2. deltaInDays(Date start, Date end)
  3. deltaMonths(Date start, Date end)
  4. divMonth(Date startDate, Date enDate)
  5. endOfDay(Date aDate)
  6. endOfDay(Date date)
  7. endOfDay(Date date)
  8. endOfDay(Date date)
  9. endOfDay(Date date)