Java Parse Time parseTime(String date, String format)

Here you can find the source of parseTime(String date, String format)

Description

parse Time

License

LGPL

Declaration

public static Date parseTime(String date, String format) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String DEFAULT_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Date parseTime(String date, String format) {
        if (date == null) {
            return null;
        }/*from   w  ww .  j a v a 2  s .  c o  m*/
        try {
            return new SimpleDateFormat(format).parse(date);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

    public static Date parseTime(String date) {
        return parseTime(date, DEFAULT_TIME_FORMAT);
    }
}

Related

  1. parseTime(Calendar c, String time)
  2. parseTime(char[] timeChars)
  3. ParseTime(final String time)
  4. parseTime(String currDate, String format)
  5. parseTime(String s)
  6. parseTime(String sTime)
  7. parseTime(String str)
  8. parseTime(String str)