get Next Day Start java.sql.Timestamp - Java java.sql

Java examples for java.sql:Timestamp

Description

get Next Day Start java.sql.Timestamp

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static java.sql.Timestamp getNextDayStart(
            java.sql.Timestamp stamp) {
        return getDayStart(stamp, 1);
    }/*from w  w w  .j  a v a2 s  .c  o  m*/

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

    public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp,
            int daysLater) {
        Calendar tempCal = Calendar.getInstance();

        tempCal.setTime(new java.util.Date(stamp.getTime()));
        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);
        return new java.sql.Timestamp(tempCal.getTime().getTime());
    }
}

Related Tutorials