Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long parseTimeStamp(String timeStamp) throws ParseException { SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss"); Date date; try { date = format.parse(timeStamp); } catch (ParseException e) { SimpleDateFormat optFormat = new SimpleDateFormat("yy-MM-dd HH:mm"); date = optFormat.parse(timeStamp); } return date.getTime(); } }