Here you can find the source of Hours()
public static String Hours()
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static String Hours() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int date = c.get(Calendar.DATE); int hour = c.get(Calendar.HOUR_OF_DAY); return year + "-" + (month < 10 ? "0" : "") + month + "-" + (date < 10 ? "0" : "") + date + "-" + (hour < 10 ? "0" : "") + hour; }/*from ww w . ja va 2 s. co m*/ }