get First Hour Today - Java java.util

Java examples for java.util:Hour

Description

get First Hour Today

Demo Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getFirstHourToday());
    }/*from  w  w w.  ja v  a 2s.co  m*/

    public static Calendar getFirstHourToday() {
        return getFirstHourDay(new Date());
    }

    public static Calendar getFirstHourDay(Date date) {
        Calendar calendar = GregorianCalendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 00);
        return calendar;
    }
}

Related Tutorials