Here you can find the source of formattedStringToDate(String date)
Parameter | Description |
---|---|
date | a parameter |
public static Date formattedStringToDate(String date)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*w w w. j a va 2 s . c o m*/ * Defines the format of each string that represent a date in our project. * The pattern is "dd.MM.yyyy HH:mm:ss" */ public static final String DATEPATTERN = "dd.MM.yyyy HH:mm:ss"; /** * Converts a String that represents a Date with the format of DATEPATTERN into a Date-Object * @param date * @return */ public static Date formattedStringToDate(String date) { SimpleDateFormat formatter = new SimpleDateFormat(DATEPATTERN); try { return formatter.parse(date); } catch (ParseException e) { e.printStackTrace(); return null; } } }