Java Timestamp Format getFormattedTime(long timestamp, String format)

Here you can find the source of getFormattedTime(long timestamp, String format)

Description

get Formatted Time

License

Open Source License

Declaration

public static String getFormattedTime(long timestamp, String format) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static final String TIMESTAMP_FORMAT = "y-MM-dd_HH-mm-ss";

    public static String getFormattedTime(long timestamp, String format) {
        if (format == null) {
            format = TIMESTAMP_FORMAT;//from  w  ww . j av a2 s. c  o  m
        }

        SimpleDateFormat dateformat = new SimpleDateFormat(format);

        return dateformat.format(new Date(timestamp));
    }
}

Related

  1. getCalendar(String timeStamp, final String dateFormat)
  2. getEpochTime(String dateTimeStamp, SimpleDateFormat dateFormat)
  3. getFormatForTimestamp( final Calendar now, final Calendar timestamp)
  4. getFormattedDate(String timestamp)
  5. getFormattedDateFromTimestamp(long timestamp)
  6. getFormattedTimestamp()
  7. getFormattedTimestamp(@Nonnull Date date)
  8. getFormattedTimestamp(File file)
  9. getFormattedTimeStamp(long timestamp, String formatString)