Here you can find the source of printTime()
public static void printTime()
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static void printTime() { System.out.println(getTime()); }/*w w w .ja va2s . c om*/ public static String getTime() { return dateFormat.format(new Date()); } }