Java Today endOfToday()

Here you can find the source of endOfToday()

Description

end Of Today

License

Creative Commons License

Declaration

public static Date endOfToday() 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

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

public class Main {
    protected static Calendar CALENDAR = Calendar.getInstance();

    /**//w  w w.j  a  v  a2  s  .c o m
     * 
     * @return
     * @see #endOfDay(Date)
     */
    public static Date endOfToday() {
        return endOfDay(new Date());
    }

    /**
     * Get the last hour, minute, second of the date specified
     * @param date
     * @return
     */
    public static Date endOfDay(Date date) {
        Calendar calendar = CALENDAR;
        synchronized (calendar) {
            calendar.setTime(date);
            calendar.set(Calendar.HOUR_OF_DAY, 23);
            calendar.set(Calendar.MILLISECOND, 999);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MINUTE, 59);
            return calendar.getTime();
        }
    }
}

Related

  1. converTimeToDayStartEnd(long time, long[] out)
  2. createTodayDirectory(File destDir)
  3. createTodayDirectory(File destDir, String inputFileName)
  4. createTodayPrefixedDirectory(final String prefix, final File parent)
  5. deletePreviousDay(Calendar today, String temppath)
  6. formatToday()
  7. formatToday()
  8. formatToDays(Date date)
  9. getAllToday()