Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getCurrentDateTime() { DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HHmmss"); Calendar cal = Calendar.getInstance(); String currentDateTime = dateFormat.format(cal.getTime()); return currentDateTime; } }