Java SQL Date Create getDayStart(Date stamp)

Here you can find the source of getDayStart(Date stamp)

Description

get Day Start

License

Open Source License

Declaration

public static java.sql.Timestamp getDayStart(Date stamp) 

Method Source Code

//package com.java2s;
/*/*w  ww .  j a  va2  s.c om*/
 * DateTimeUtils.java
 *
 * Copyright (c) 1998 - 2006 BusinessTechnology, Ltd.
 * All rights reserved
 *
 * This program is the proprietary and confidential information
 * of BusinessTechnology, Ltd. and may be used and disclosed only
 * as authorized in a license agreement authorizing and
 * controlling such use and disclosure
 *
 * Millennium ERP system.
 *
 */

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

public class Main {
    public static java.sql.Timestamp getDayStart(Date stamp) {
        return getDayStart(stamp, 0);
    }

    public static java.sql.Timestamp getDayStart(Date stamp, int daysLater) {
        Calendar tempCal = Calendar.getInstance();
        tempCal.setTime(stamp);
        tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0,
                0, 0);
        tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
        java.sql.Timestamp retStamp = new java.sql.Timestamp(tempCal.getTime().getTime());
        retStamp.setNanos(0);
        return retStamp;
    }
}

Related

  1. getDay(String stringDate)
  2. getDayByMonthSeed(Date date, int monthSeed)
  3. getDayByWeekString(Date date, String weekString)
  4. getDays(Date from, Date to)
  5. getDaysLater(Date date, int days)
  6. getLastDateOfQuarter()
  7. getLastDay(Date date)
  8. getLastDay(Date dt)
  9. getLastDay(java.util.Date dt)