Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Locale; public class Main { public static String getSystemTime(boolean hour24Mode) { // yyyy-MM-dd hh:mm:ss String format = "HH:mm"; if (!hour24Mode) { format = "hh:mm"; } SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US); String date = sdf.format(new java.util.Date()); return date; } }