Java Timestamp Format getFormattedTimestamp(File file)

Here you can find the source of getFormattedTimestamp(File file)

Description

get Formatted Timestamp

License

Open Source License

Declaration

public static String getFormattedTimestamp(File file) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Salesforce.com, inc..
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * /* ww  w  . ja  v  a 2s.com*/
 * Contributors:
 *     Salesforce.com, inc. - initial API and implementation
 ******************************************************************************/

import java.io.File;

import java.text.DateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    public static String getFormattedTimestamp(File file) {
        return file != null && file.exists() ? getLocaleFormattedDateTime(file.lastModified()) : null;
    }

    public static String getLocaleFormattedDateTime(long datetime) {
        return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, Locale.getDefault())
                .format(new Date(datetime));
    }
}

Related

  1. getFormattedDate(String timestamp)
  2. getFormattedDateFromTimestamp(long timestamp)
  3. getFormattedTime(long timestamp, String format)
  4. getFormattedTimestamp()
  5. getFormattedTimestamp(@Nonnull Date date)
  6. getFormattedTimeStamp(long timestamp, String formatString)
  7. getFullTimestampFormatter(Locale locale)
  8. getTimestamp(boolean useTwentyFourFormat)
  9. getTimeStamp(String format)