Java String to Date rfc3339ToDate(String s)

Here you can find the source of rfc3339ToDate(String s)

Description

Convert an RFC 3309 String to a Date.

License

Open Source License

Parameter

Parameter Description
s the String

Exception

Parameter Description
ParseException thrown if a syntax error occurred

Return

the Date

Declaration

public static Date rfc3339ToDate(String s) throws ParseException 

Method Source Code


//package com.java2s;
// compliance with the InfoGrid license. The InfoGrid license and important

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

public class Main {
    /**//from www  . j  a v  a2s.com
     * Date format to use for RFC 3339.
     */
    public static final SimpleDateFormat theRfc3339Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

    /**
     * Convert an RFC 3309 String to a Date.
     *
     * @param s the String
     * @return the Date
     * @throws ParseException thrown if a syntax error occurred
     */
    public static Date rfc3339ToDate(String s) throws ParseException {
        s = s.toUpperCase();

        Date ret = theRfc3339Format.parse(s);

        return ret;
    }
}

Related

  1. longToDateString(long l)
  2. longToDateStringDefault(long time)
  3. numberToDate(String dateString)
  4. putTimeStr14ToDate(String dateTimeStr)
  5. putTimeStr19ToDate(String dateTimeStr19)
  6. SortStringToDate(String thisdate, Locale locale)
  7. strChangeToDate(String str)
  8. strDateConvertToDate(String strDate, String fFormatStr)
  9. stringArrayTODateArray(String[] dates_s, SimpleDateFormat dateformat)