Here you can find the source of getCurrentUTCSeconds(Date current)
@SuppressWarnings("deprecation") public static int getCurrentUTCSeconds(Date current)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static SimpleDateFormat stringDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); private static final SimpleDateFormat defaultFormater = new SimpleDateFormat("yyyyMMdd"); private static final SimpleDateFormat customizedFormater = new SimpleDateFormat("yyyyMMdd"); @SuppressWarnings("deprecation") public static int getCurrentUTCSeconds() { Date _current = Calendar.getInstance().getTime(); String dt = stringDateTimeFormat.format(_current); String tempDateTime[] = dt.split("-"); int yy = Integer.parseInt(tempDateTime[0]); int MM = Integer.parseInt(tempDateTime[1]); int dd = Integer.parseInt(tempDateTime[2]); int HH = Integer.parseInt(tempDateTime[3]); int mm = Integer.parseInt(tempDateTime[4]); int ss = Integer.parseInt(tempDateTime[5]); return (int) (Date.UTC(yy, MM, dd, HH, mm, ss) / 1000 % 86400); }//from w w w . j av a 2 s.c o m @SuppressWarnings("deprecation") public static int getCurrentUTCSeconds(Date current) { String dt = stringDateTimeFormat.format(current); String tempDateTime[] = dt.split("-"); int yy = Integer.parseInt(tempDateTime[0]); int MM = Integer.parseInt(tempDateTime[1]); int dd = Integer.parseInt(tempDateTime[2]); int HH = Integer.parseInt(tempDateTime[3]); int mm = Integer.parseInt(tempDateTime[4]); int ss = Integer.parseInt(tempDateTime[5]); return (int) (Date.UTC(yy, MM, dd, HH, mm, ss) / 1000 % 86400); } public static String getTime() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); return formatter.format(currentTime); } public static String format(Date date, String pattern) { synchronized (customizedFormater) { if (null != pattern && !"".equals(pattern.trim())) { customizedFormater.applyPattern(pattern); } else { throw new IllegalArgumentException("pattern can not be empty"); } return customizedFormater.format(date); } } public static String format(Date date) { synchronized (defaultFormater) { return defaultFormater.format(date); } } }