Android Long to Date Convert getFormattedTime(String dateTimeFormat, long timestamp)

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

Description

Method to get the current date-time in the input format.

Parameter

Parameter Description
dateTimeFormat the date-time format
timestamp the timestamp to be formatted

Return

the current date-time in the input format

Declaration

public static String getFormattedTime(String dateTimeFormat,
        long timestamp) 

Method Source Code

//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    /**//from w w  w  .  j  a  v a2  s. c o m
     * Method to get the current date-time in the input format.
     * 
     * @param dateTimeFormat
     *            the date-time format
     * @param timestamp
     *            the timestamp to be formatted
     * @return the current date-time in the input format
     */
    public static String getFormattedTime(String dateTimeFormat,
            long timestamp) {
        Date date = new Date(timestamp);
        SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat,
                Locale.US);
        return sdf.format(date);
    }
}

Related

  1. getDay(long dateTimeMillis)
  2. getDayOfWeek(long timeMillis)
  3. getDefaultDateTimeString(long date, Locale locale)
  4. getDefaultDatetime(long milliseconds)
  5. getElapsedDurationSince(long seconds)
  6. getFriendlyDate(Context context, long timestamp)
  7. getHour(long dateTimeMillis)
  8. getHour(long timeMillis)
  9. getHoursAndMinutes(long dateTimeMillis)