parse Date by format yyyy-MM-dd'T'HH:mm:ss.SSS - Java java.util

Java examples for java.util:Date Format

Description

parse Date by format yyyy-MM-dd'T'HH:mm:ss.SSS

Demo Code


//package com.java2s;

import java.text.DateFormat;

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

public class Main {

    public static final DateFormat DATE_FORMAT = new SimpleDateFormat(
            "yyyy-MM-dd'T'HH:mm:ss.SSS");

    public static Date parseDate(String value) {
        Date result = null;//from w  w  w.  j  a va2s  . c om
        try {
            result = DATE_FORMAT.parse(value);
        } catch (ParseException ex) {
            // do nothing; we will just return null
        }
        return result;
    }
}

Related Tutorials