Here you can find the source of convertStringToTime(String date, String pattern)
Parameter | Description |
---|---|
date | to convert |
pattern | in converting |
public static Date convertStringToTime(String date, String pattern) throws Exception
//package com.java2s; /*// ww w . j ava 2s .c o m * Copyright (C) 2010 dungnv. All rights reserved. * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * * @param date to convert * @param pattern in converting * @return date */ public static Date convertStringToTime(String date, String pattern) throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); try { return dateFormat.parse(date); } catch (ParseException e) { System.out.println("Date ParseException, string value:" + date); throw e; } } }