Java tutorial
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; public class Main { public static String getYear_Second1() { Timestamp stamp1 = new Timestamp(System.currentTimeMillis()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String timeStr = sdf.format(stamp1); return timeStr; } }