Java Timestamp Field getMonthStartTimestamp(Date date)

Here you can find the source of getMonthStartTimestamp(Date date)

Description

get Month Start Timestamp

License

Apache License

Declaration

public static Timestamp getMonthStartTimestamp(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

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

public class Main {
    public static Timestamp getMonthStartTimestamp(Date date) {
        Date start = getMonthStartDate(date);
        return new Timestamp(start.getTime());
    }// www  . j a va  2  s.  c  o m

    public static Date getMonthStartDate(Date date) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }
}

Related

  1. getMessageTimestamp(int id)
  2. getMillTimestamp()
  3. getMonthEnd(Timestamp stamp, TimeZone timeZone, Locale locale)
  4. getMonthLastDay(Timestamp day)
  5. getMonthStart(java.sql.Timestamp stamp)
  6. getNanos(Timestamp timestamp)
  7. getNanoString(Timestamp timestamp, boolean full, char nanoSep)
  8. getNbHours(Timestamp dateA, Timestamp dateB)
  9. getNextDayStart(java.sql.Timestamp stamp)