Here you can find the source of parseToDate(String timestamp, String pattern)
Parameter | Description |
---|---|
timestamp | the timestamp |
pattern | the pattern |
public static Date parseToDate(String timestamp, String pattern)
//package com.java2s; /*/*from w w w .j a va 2 s . c o m*/ * DateUtil.java * Copyright (c) 2014, EcoFactor, All Rights Reserved. * * This software is the confidential and proprietary information of EcoFactor * ("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 * EcoFactor. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * Parses the to date. * @param timestamp the timestamp * @param pattern the pattern * @return the date */ public static Date parseToDate(String timestamp, String pattern) { Date date = null; try { date = new SimpleDateFormat(pattern, Locale.ENGLISH).parse(timestamp); } catch (ParseException e) { e.printStackTrace(); } return date; } }