Here you can find the source of getToday()
public static String getToday()
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static String getToday() { Calendar cl = Calendar.getInstance(); String month = ""; String day = ""; String today = ""; String today2 = ""; int m = cl.get(Calendar.MONTH) + 1; if (m < 10) { month = "0" + String.valueOf(m); } else {//w w w. j av a2 s.c om month = String.valueOf(m); } int d = cl.get(Calendar.DATE); if (d < 10) { day = "0" + String.valueOf(d); } else { day = String.valueOf(d); } today = cl.get(Calendar.YEAR) + month + day + cl.get(Calendar.HOUR_OF_DAY) + cl.get(Calendar.MINUTE) + cl.get(Calendar.SECOND); today2 = cl.get(Calendar.YEAR) + "-" + month + "-" + day + " " + cl.get(Calendar.HOUR_OF_DAY) + ":" + cl.get(Calendar.MINUTE) + ":" + cl.get(Calendar.SECOND); return today2; } }