Here you can find the source of parseDate(String dateVal)
Parameter | Description |
---|---|
dateVal | string value |
public static Date parseDate(String dateVal)
//package com.java2s; /*//from w w w . j a v a2s . c o m * File: $RCSfile$ * * Copyright (c) 2005 Wincor Nixdorf International GmbH, * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany * All Rights Reserved. * * This software is the confidential and proprietary information * of Wincor Nixdorf ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with Wincor Nixdorf. */ import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.text.ParseException; public class Main { /** * Parse string to date with specified pattern * * @param dateVal string value * @param datePattern date pattern * @return date converted from @param dateVal with @param datePattern */ public static Date parseDate(String dateVal, String datePattern) { Date dateFormatted = null; try { DateFormat dateFormat = new SimpleDateFormat(datePattern); dateFormatted = dateFormat.parse(dateVal); } catch (ParseException e) { e.printStackTrace(); } return dateFormatted; } /** * Parse string to date with default pattern yyyy-MM-dd * * @param dateVal string value * @return date converted from @param dateVal with default pattern */ public static Date parseDate(String dateVal) { return parseDate(dateVal, "yyyy-MM-dd"); } }