get Hour from Calendar - Java java.util

Java examples for java.util:Hour

Description

get Hour from Calendar

Demo Code


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

public class Main {


    public static int getHour() {

        Calendar c = Calendar.getInstance();

        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int date = c.get(Calendar.DATE);
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);
        int second = c.get(Calendar.SECOND);
        return hour;
    }/*from   w w  w  .j  ava2  s.  co  m*/
}

Related Tutorials