Java String to Date toDate(String dateToConvert)

Here you can find the source of toDate(String dateToConvert)

Description

This function takes a timezone string and converts it to a Java Date

License

Open Source License

Parameter

Parameter Description
dateToConvert a parameter

Exception

Parameter Description
ParseException an exception

Declaration

public static Date toDate(String dateToConvert) throws ParseException 

Method Source Code

//package com.java2s;

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

import java.util.Date;

public class Main {
    /**//from w  w w . j  a  v a 2s  . co m
     * This function takes a timezone string and converts it to a Java Date 
     * @param dateToConvert
     * @return
     * @throws ParseException
     */
    public static Date toDate(String dateToConvert) throws ParseException {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        Date date = formatter.parse(dateToConvert);
        return date;
    }
}

Related

  1. toDate(String dateString)
  2. toDate(String dateString, Locale locale)
  3. toDate(String dateString, String dateFormatPattern)
  4. toDate(String dateString, String format)
  5. toDate(String datetime)
  6. toDate(String dateToDatify)
  7. toDate(String dateValue, String format)
  8. toDate(String format, String str)
  9. toDate(String formatDate, String stringDate)