Java Time Parse getTimeFileName(String suffix)

Here you can find the source of getTimeFileName(String suffix)

Description

get Time File Name

License

Apache License

Parameter

Parameter Description

Return

String

Declaration

public static String getTimeFileName(String suffix) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getTimeFileName(String suffix) {
        return formatDate(new Date(), "yyyyMMddHHmmssSSS") + suffix;
    }/* w w  w  .  jav  a 2s .  com*/

    public static String formatDate(Date date, String patter) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(patter);
            return sdf.format(date);
        } catch (RuntimeException e) {
            return "";
        }
    }

    public static String formatDate(Date date) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return sdf.format(date);
        } catch (RuntimeException e) {
            return "";
        }
    }
}

Related

  1. getTimeFromGermanLocale(String timeString)
  2. getTimeFromJsToJava(String date)
  3. getTimeFromString(String time)
  4. getTimeList(String start, String end, int pitch)