create File Name from current time in yyyy-MM-dd-HH-mm-ss format - Android java.io

Android examples for java.io:File Name

Description

create File Name from current time in yyyy-MM-dd-HH-mm-ss format

Demo Code

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

public class Main {

  private static final String DEFAULT_FILE_PATTERN = "yyyy-MM-dd-HH-mm-ss";

  public static String createFileName() {
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat format = new SimpleDateFormat(DEFAULT_FILE_PATTERN);
    return format.format(date);
  }//  w w w .  j  a  va  2 s .  co  m

}

Related Tutorials