get Now Hour - Java java.util

Java examples for java.util:Hour

Description

get Now Hour

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getNowHour());
    }/*  www  .j a va2  s . c o m*/

    public static final SimpleDateFormat HH = new SimpleDateFormat("HH");

    public static Integer getNowHour() {
        HH.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
        return Integer.parseInt(HH.format(new Date()));
    }
}

Related Tutorials