Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.text.SimpleDateFormat; import java.util.Locale; public class Main { /** * Get datetime * * @return */ public static String getDateTime() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); Date date = new Date(); return dateFormat.format(date); } }