Here you can find the source of parseTimestamp(String value)
Parameter | Description |
---|---|
value | a value to parse |
public static Date parseTimestamp(String value)
//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; } } }