Here you can find the source of dayToUTCSeconds(String day)
Parameter | Description |
---|---|
day | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static long dayToUTCSeconds(String day) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.TimeZone; public class Main { /**/* w w w.j a v a2 s .c om*/ * Convert String of day to epoch time for UTC * @param day * @return * @throws ParseException */ public static long dayToUTCSeconds(String day) throws ParseException { return dayToSeconds(day, "UTC"); } /** * Convert String of day to epoch time for targeted time zone. * @param day * @param timeZone * @return * @throws ParseException */ public static long dayToSeconds(String day, String timeZone) throws ParseException { return dayToMilliSeconds(day, timeZone) / 1000; } /** * Convert String of day to epoch time for targeted time zone. * @param day * @param timeZone * @return * @throws ParseException */ public static long dayToMilliSeconds(String day, String timeZone) throws ParseException { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); return simpleDateFormat.parse(day).getTime(); } }