Java Timestamp Parse parseTimestamp(String date)

Here you can find the source of parseTimestamp(String date)

Description

parse Timestamp

License

Apache License

Declaration

public static Date parseTimestamp(String date) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static Date parseTimestamp(String date) throws ParseException {
        return getTimetampFormat().parse(date);
    }//w w  w  .j a v a2  s  .  c  om

    public static Date parse(String date) throws ParseException {
        try {
            return parseTimestamp(date);
        } catch (ParseException e) {
            return parseDate(date);
        }
    }

    public static DateFormat getTimetampFormat() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    public static Date parseDate(String date) throws ParseException {
        return getDateFormat().parse(date);
    }

    public static DateFormat getDateFormat() {
        return new SimpleDateFormat("yyyy-MM-dd");
    }
}

Related

  1. parseTimestamp(final String s)
  2. parseTimeStamp(final String... key)
  3. parseTimestamp(Long time, String pattern)
  4. parseTimestamp(Object o)
  5. parseTimestamp(String d)
  6. parseTimestamp(String dateStr, String format)
  7. parseTimestamp(String dateString)
  8. parseTimestamp(String pattern, String dateTime)
  9. parseTimestamp(String s)