Here you can find the source of parseTimestamp(final String format, final String time)
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") private static long parseTimestamp(final String format, final String time)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Map; import java.util.WeakHashMap; public class Main { private static final Map<String, DateFormat> c_formats = new WeakHashMap<String, DateFormat>(); @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") private static long parseTimestamp(final String format, final String time) { try {//from w w w. ja v a2 s. c om final DateFormat dateFormat = getDateFormat(format); synchronized (dateFormat) { return dateFormat.parse(time).getTime(); } } catch (final Exception e) { return 0; } } private static DateFormat getDateFormat(final String format) { synchronized (c_formats) { DateFormat dateFormat = c_formats.get(format); if (null == dateFormat) { dateFormat = new SimpleDateFormat(format); c_formats.put(format, dateFormat); } return dateFormat; } } }