Makes a Timestamp for the beginning of the month - Java java.sql

Java examples for java.sql:Timestamp

Description

Makes a Timestamp for the beginning of the month

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    /**//www.jav a2  s  . co  m
     * Makes a Timestamp for the beginning of the month
     * 
     * @return A Timestamp of the beginning of the month
     */
    public static java.sql.Timestamp monthBegin() {
        Calendar mth = Calendar.getInstance();

        mth.set(Calendar.DAY_OF_MONTH, 1);
        mth.set(Calendar.HOUR_OF_DAY, 0);
        mth.set(Calendar.MINUTE, 0);
        mth.set(Calendar.SECOND, 0);
        mth.set(Calendar.AM_PM, Calendar.AM);
        return new java.sql.Timestamp(mth.getTime().getTime());
    }
}

Related Tutorials