Java Time Format getFormattedFileTime(File f, String format)

Here you can find the source of getFormattedFileTime(File f, String format)

Description

get Formatted File Time

License

Open Source License

Parameter

Parameter Description
f a parameter
format a parameter

Declaration

public static String getFormattedFileTime(File f, String format) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    /**/*from  ww  w. j  a v a2  s.  c  o  m*/
     * @param f
     * @param format
     * @return
     */
    public static String getFormattedFileTime(File f, String format) {
        try {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(f.lastModified());
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            return sdf.format(cal.getTime());
        } catch (SecurityException ignored) {
            return "";
        }

    }
}

Related

  1. getFormattedCurrentDateTime(String pattern)
  2. getFormattedDateAndTime(final Date date)
  3. getFormattedDateTime(Date date, String pattern)
  4. getFormattedDateTime(String date, String dateFormat)
  5. getFormattedDuration(long fromTime)
  6. getFormattedTime()
  7. getFormattedTime(Date date)
  8. getFormattedTime(Date date)
  9. getFormattedTime(final Calendar calendar)