Java Parse Date ParseDate(String string, String format)

Here you can find the source of ParseDate(String string, String format)

Description

Tries to parse string into a Date(+time), using given format.

License

Open Source License

Return

null if parsing fails

Declaration

static private Date ParseDate(String string, String format) 

Method Source Code


//package com.java2s;

import java.util.*;

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

public class Main {
    /** Tries to parse string into a Date(+time), using given format. 
     * @return null if parsing fails//w w  w .  j  a va2s. c om
     */
    static private Date ParseDate(String string, String format) {
        try {
            return new SimpleDateFormat(format).parse(string);
        } catch (ParseException exc) {
        } // OK, 'expected' exception 
        return null;
    }
}

Related

  1. parseDate(String strDate)
  2. parseDate(String strDate)
  3. parseDate(String strDate, String format)
  4. parseDate(String strFormat, String dateValue)
  5. parseDate(String string)
  6. parseDate(String t)
  7. parseDate(String text)
  8. parseDate(String text, String[] datePattern, int index)
  9. parseDate(String time)