Here you can find the source of parse(String time)
public static Date parse(String time)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat day = new SimpleDateFormat("yyyy-MM-dd"); public static final SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static final SimpleDateFormat microSeconds = new SimpleDateFormat("yyyyMMddHHmmssSSS"); public static Date parse(String time) { if (time == null || time.isEmpty()) return null; try {//from w ww . j ava 2 s . co m return dayTime.parse(time); } catch (Exception ex) { } try { return day.parse(time); } catch (Exception e) { } if (time.matches("\\d{10,17}")) { if (time.length() == 17) { try { return microSeconds.parse(time); } catch (Exception e) { } } else if (time.length() == 13) { return new Date(Long.valueOf(time)); } else if (time.length() == 10) { return new Date(Long.valueOf(time) * 1000); } } return null; } }