Here you can find the source of getTodayAsSecond()
public static String getTodayAsSecond()
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getTodayAsSecond() { return getTodayAsSecond(0); }/*from w ww .ja va 2 s . c o m*/ /** * Gets today as second. * * @return the today as second */ public static String getTodayAsSecond(int d) { String result = "0"; DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); try { calendar.add(Calendar.DAY_OF_YEAR, d); Date date = df.parse(df.format(calendar.getTime())); calendar.setTime(date); result = Long.toString(calendar.getTimeInMillis() / 1000); } catch (ParseException e) { e.printStackTrace(); } return result; } }