Here you can find the source of toDate(String patten, String value)
Parameter | Description |
---|---|
patten | the patten |
value | the value |
public static Date toDate(String patten, String value)
//package com.java2s; /**// w w w. j a v a2 s .co m * ********************************************************************* * Copyright (c) 2015 InfoZen, Inc. All rights reserved. InfoZen * PROPRIETARY/CONFIDENTIAL. Usage is subject to license terms. * ********************************************************************* */ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * To date. * * @param patten * the patten * @param value * the value * @return the date */ public static Date toDate(String patten, String value) { DateFormat formater = new SimpleDateFormat(patten); try { return formater.parse(value); } catch (ParseException e) { throw new IllegalArgumentException(e); } } }