Java tutorial
//package com.java2s; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static int toH(long time) { Date dat = new Date(time); GregorianCalendar gc = new GregorianCalendar(); gc.setTime(dat); java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("HH"); String sb = format.format(gc.getTime()); int i = Integer.parseInt(sb); return i; } }