Android File Name Create getLocalDateTimeForFileName(Date date)

Here you can find the source of getLocalDateTimeForFileName(Date date)

Description

Return current date time as a concatenated string, to be used as filename.

Parameter

Parameter Description
date a parameter

Declaration

public static String getLocalDateTimeForFileName(Date date) 

Method Source Code

//package com.java2s;

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

import java.util.TimeZone;

public class Main {
    /**//from  www . j  a v  a  2s .c om
     * Return current date time as a concatenated string, to be used as filename.
     * @param date
     * @return
     */
    public static String getLocalDateTimeForFileName(Date date) {

        final SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyy_HHmmss");
        sdf.setTimeZone(TimeZone.getDefault());
        return sdf.format(date);
    }
}

Related

  1. makeFileName(String prefix, String filename)
  2. createImageName()
  3. getJpegFileName(long fileNumber)
  4. getMetadataFileName(long fileNumber)
  5. getYuvFileName(long fileNumber)