Java Timestamp Parse parseTimestamp(String timestamp, String dateFormat, Locale locale)

Here you can find the source of parseTimestamp(String timestamp, String dateFormat, Locale locale)

Description

parse Timestamp

License

Open Source License

Declaration

public static Calendar parseTimestamp(String timestamp, String dateFormat, Locale locale)
            throws ParseException 

Method Source Code

//package com.java2s;
/**/*from  ww  w.  j  a v a 2  s  . com*/
 * CanReg5 - a tool to input, store, check and analyse cancer registry data.
 * Copyright (C) 2008-2015 International Agency for Research on Cancer
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Morten Johannes Ervik, CSU/IARC, ervikm@iarc.fr
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static Calendar parseTimestamp(String timestamp, String dateFormat, Locale locale)
            throws ParseException {
        /*
         ** we specify Locale.US since months are in english
         */
        if (locale == null) {
            locale = Locale.getDefault();
        }
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, locale);
        Date d = sdf.parse(timestamp);
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        return cal;
    }
}

Related

  1. parseTimestamp(String timestamp)
  2. parseTimeStamp(String timeStamp)
  3. parseTimestamp(String timestamp)
  4. parseTimestamp(String timestamp)
  5. parseTimeStamp(String timeStamp)
  6. parseTimeStamp(String timeStampString)
  7. parseTimestamp(String value)
  8. parseTimestamp(String value)
  9. parseTimestamp2Long(String datestring, String datepattern, TimeZone timeZone)