Java Day End getStartAndEndDate(Date d)

Here you can find the source of getStartAndEndDate(Date d)

Description

return starting and ending dates within a day

License

Open Source License

Declaration

public static Date[] getStartAndEndDate(Date d) 

Method Source Code

//package com.java2s;
/*/*from   ww  w .  j  a v  a 2 s  . c  om*/
 * All GTAS code is Copyright 2016, Unisys Corporation.
 * 
 * Please see LICENSE.txt for details.
 */

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

public class Main {
    /**
     * return starting and ending dates within a day 
     */
    public static Date[] getStartAndEndDate(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date startDate = cal.getTime();

        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        Date endDate = cal.getTime();

        return new Date[] { startDate, endDate };
    }
}

Related

  1. getNumMonths(Date dStart, Date dEnd)
  2. getNumYears(Date dStart, Date dEnd)
  3. getSCDEndDate()
  4. getSecondSemesterEndDate(Integer year)
  5. getSendTime(Date sendDate, Date start, Date end)
  6. getStartOrEndTime(Date date, int flag)
  7. getSubSeconds(Date minuendDate, Date subDate)
  8. getTimeBeetweenDates(Date d1, Date d2, int timeType)
  9. getTimeInterval(Date startDate, Date endDate)