Java SQL Date Month getMonthStart(Date stamp)

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

Description

Return the date for the first day of the month

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
/*/* w w  w .ja  va2s. c  o  m*/
 * 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 {
    /**
     * Return the date for the first day of the month
     */
    public static java.sql.Timestamp getMonthStart(Date stamp) {
        return getMonthStart(stamp, 0);
    }

    public static java.sql.Timestamp getMonthStart(Date stamp, int daysLater) {
        Calendar tempCal = Calendar.getInstance();
        tempCal.setTime(stamp);
        tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), 1, 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. getMonthAmount(java.sql.Date _startDate, java.sql.Date _endDate)
  2. getMonthBefroe(Date date)
  3. getMonthDate(Date myDate, int month)
  4. getMonthDays(java.sql.Date date)
  5. getMonthFromYMD(Date ymd)
  6. getMulmonthday(String startdate, String enddate)
  7. getNextMonthFirstDate(java.sql.Date date)
  8. getNextMonthStartDate(Date date)
  9. getSqlDate(final int iDay, final int iMonth, final int iYear)