Java Timestamp Parse parseToDate(String timestamp, String pattern)

Here you can find the source of parseToDate(String timestamp, String pattern)

Description

Parses the to date.

License

Open Source License

Parameter

Parameter Description
timestamp the timestamp
pattern the pattern

Return

the date

Declaration

public static Date parseToDate(String timestamp, String pattern) 

Method Source Code


//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;
    }
}

Related

  1. parseTimestamp(String value)
  2. parseTimestamp(String value)
  3. parseTimestamp2Long(String datestring, String datepattern, TimeZone timeZone)
  4. parseTimestampDirectory(final String stamp)
  5. parseTimestampToString(Timestamp stamp, String dateFormat)
  6. str2Timestamp(String str)
  7. String2Timestamp(String date)
  8. String2Timestamp(String s, String fmt)
  9. string2Timestamp(String strDateTime, String pattern)