get First Hour Day - Java java.util

Java examples for java.util:Hour

Description

get First Hour Day

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 {
        Date date = new Date();
        System.out.println(getFirstHourDay(date));
    }//w  w  w .ja  va  2s .c  o m

    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