Java Timestamp Parse parseTimestampDirectory(final String stamp)

Here you can find the source of parseTimestampDirectory(final String stamp)

Description

parse Timestamp Directory

License

Open Source License

Declaration

public static Date parseTimestampDirectory(final String stamp)
            throws ParseException 

Method Source Code

//package com.java2s;

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

public class Main {
    private static final String TSDIR_SECONDS_FORMAT = "yyyyMMdd_HHmmss";
    private static final String TSDIR_MILLISECONDS_FORMAT = "yyyyMMdd_HHmmssSSS";

    public static Date parseTimestampDirectory(final String stamp)
            throws ParseException {
        final DateFormat format;
        if (stamp.length() == 18) {
            format = new SimpleDateFormat(TSDIR_MILLISECONDS_FORMAT);
        } else {/*from www.  j  a  va  2s. c  om*/
            format = new SimpleDateFormat(TSDIR_SECONDS_FORMAT);
        }

        return format.parse(stamp);
    }
}

Related

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