Java Timestamp Parse parseTimestamp(String value)

Here you can find the source of parseTimestamp(String value)

Description

Parse UNIX timestamp as it is returned by the

License

Apache License

Parameter

Parameter Description
value a value to parse

Return

timestamp as object

Declaration

public static Date parseTimestamp(String value) 

Method Source Code

//package com.java2s;
/*//from w ww.  j  a  v a2  s  . c  om
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    /**
     * Parse UNIX timestamp as it is returned by the
     *
     * @param value a value to parse
     * @return timestamp as {@link java.util.Date} object
     */
    public static Date parseTimestamp(String value) {
        //20101116.152312
        final String pattern = "yyyyMMdd.HHmmss";
        if (value != null && value.length() >= pattern.length()) {
            try {
                return new SimpleDateFormat(pattern).parse(value);
            } catch (ParseException e) {
                throw new IllegalArgumentException(e);
            }
        } else {
            return null;
        }
    }
}

Related

  1. parseTimestamp(String timestamp)
  2. parseTimeStamp(String timeStamp)
  3. parseTimestamp(String timestamp, String dateFormat, Locale locale)
  4. parseTimeStamp(String timeStampString)
  5. parseTimestamp(String value)
  6. parseTimestamp2Long(String datestring, String datepattern, TimeZone timeZone)
  7. parseTimestampDirectory(final String stamp)
  8. parseTimestampToString(Timestamp stamp, String dateFormat)
  9. parseToDate(String timestamp, String pattern)