Here you can find the source of convertStringToDate(String dateString, String currentFormat)
Parameter | Description |
---|---|
dateString | date string |
currentFormat | format string specifying the current format of date |
public static Date convertStringToDate(String dateString, String currentFormat) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**/*from w ww . j a v a 2 s . c om*/ * used to convert the specified date string to Date instance * * @param dateString date string * @param currentFormat format string specifying the current format of date * @return returns Date instance in "day MMM dd HH:MM:SS Timzone yyyy" * format */ public static Date convertStringToDate(String dateString, String currentFormat) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat(currentFormat, Locale.getDefault()); return dateFormat.parse(dateString); } }