Java tutorial
//package com.java2s; //License from project: LGPL import java.util.Calendar; public class Main { public static String getCurrentHour() { Calendar calendar = Calendar.getInstance(); int nHour = calendar.get(Calendar.HOUR_OF_DAY); if (nHour < 10) return "0" + Integer.toString(nHour); else return Integer.toString(nHour); } }