Here you can find the source of parseTimestamp(Object o)
Parameter | Description |
---|---|
o | A timestamp string as 'HH:mm:ss' or 'HH:mm'. |
public static long parseTimestamp(Object o)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { /**/*from www . j a v a2 s .c o m*/ * @param o A timestamp string as 'HH:mm:ss' or 'HH:mm'. * @return Epoch time or 0 if there is a problem parsing the timestamp string. */ public static long parseTimestamp(Object o) { String timestamp = o.toString(); SimpleDateFormat sdf; if (timestamp.length() == 8) { sdf = new SimpleDateFormat("HH:mm:ss"); } else if (timestamp.length() == 5) { sdf = new SimpleDateFormat("HH:mm"); } else { return (0L); } try { return (sdf.parse(timestamp).getTime()); } catch (ParseException e) { return (0L); } } }