Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static String getCurrentTime() { Calendar calendar = Calendar.getInstance(); return getToday() + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE); } public static String getToday() { Calendar calendar = Calendar.getInstance(); int month = calendar.get(Calendar.MONTH) + 1; return calendar.get(Calendar.YEAR) + "-" + ((month < 10) ? "0" + month : "" + month) + "-" + calendar.get(Calendar.DAY_OF_MONTH); } }