Here you can find the source of getFormattedCurrentDateAndTime()
public static String getFormattedCurrentDateAndTime()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getFormattedCurrentDateAndTime() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(System.currentTimeMillis()); return formatter.format(date); }/*from w ww.j a v a 2s. c om*/ }