Here you can find the source of parse(String str)
public static long parse(String str)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Map; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; public class Main { private static final Map<String, Long> map = new ConcurrentHashMap<String, Long>(); public static long parse(String str) { int len = str.length(); String date = str.substring(0, 10); Long baseline = map.get(date); if (baseline == null) { try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); format.setTimeZone(TimeZone.getTimeZone("GMT+8")); baseline = format.parse(date).getTime(); map.put(date, baseline); } catch (ParseException e) { return -1; }/*ww w. j av a 2 s . c o m*/ } long time = baseline.longValue(); long metric = 1; boolean millisecond = true; for (int i = len - 1; i > 10; i--) { char ch = str.charAt(i); if (ch >= '0' && ch <= '9') { time += (ch - '0') * metric; metric *= 10; } else if (millisecond) { millisecond = false; } else { metric = metric / 100 * 60; } } return time; } }