Here you can find the source of parseDate(String sDateTime, String sPattern)
Parameter | Description |
---|---|
sDateTime | The String value that contains the date. |
sPattern | The String value that contains the pattern to use (ie. "yyyy/MM/dd hh:mm:ss") during the conversion. |
public static Date parseDate(String sDateTime, String sPattern)
//package com.java2s; import java.text.*; import java.util.*; public class Main { /**//from w w w .j a v a2 s . c o m * The date format manager. This handles all the date formatting functionality. */ private static SimpleDateFormat fmtDateHandler = new SimpleDateFormat(); /** * Parse the String to return a valid Date object. <p> This method uses the time zone. * @param sDateTime The String value that contains the date. * @param sPattern The String value that contains the pattern to use * (ie. "yyyy/MM/dd hh:mm:ss") during the conversion. */ public static Date parseDate(String sDateTime, String sPattern) { TimeZone timeZone = TimeZone.getDefault(); Date date = parseDate(sDateTime, sPattern, timeZone); return date; } /** * Parse the String to return a valid Date object. * @param sDateTime The String value that contains the date. * @param sPattern The String value that contains the pattern to use * (ie. "yyyy/MM/dd hh:mm:ss") during the conversion. * @param timeZone The specified time zone to use during the conversion. */ public static Date parseDate(String sDateTime, String sPattern, TimeZone timeZone) { ParsePosition pos = new ParsePosition(0); fmtDateHandler.applyPattern(sPattern); fmtDateHandler.setTimeZone(timeZone); // Parse the input string. return fmtDateHandler.parse(sDateTime, pos); } }