Java String to Timestamp getTimestamp(String pattern)

Here you can find the source of getTimestamp(String pattern)

Description

get Timestamp

License

Open Source License

Declaration

public static String getTimestamp(String pattern) 

Method Source Code


//package com.java2s;

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

public class Main {
    static final Locale currentLocale = Locale.getDefault();

    public static String getTimestamp(String pattern) {
        return getTime(new Date(), pattern, currentLocale);
    }/*from   ww  w.j  ava 2s.c o m*/

    public static String getTimestamp(String pattern, Locale locale) {
        return getTime(new Date(), pattern, locale);
    }

    public static String getTime(Date date, String pattern) {
        return getTime(date, pattern, currentLocale);
    }

    public static String getTime(Date date, String pattern, Locale locale) {
        SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
        return formatter.format(date);
    }
}

Related

  1. getFileNameWithTimeStampInterposed(final String fileName)
  2. getStringToTimestamp(String string)
  3. getTimeStamp(String date)
  4. getTimeStamp(String dateTime)
  5. getTimestamp(String dateValue, String pattern, TimeZone timezone)
  6. getTimeStamp(String pattern, String strDate)
  7. getTimeStamp(String style, Date date)
  8. getTimestamp(String timeStampStr, String logRundateIdStr)
  9. getTimestamp(String timezone, String dateTime, String pattern)