Java Date Now getCurrentTimeForFileName()

Here you can find the source of getCurrentTimeForFileName()

Description

get Current Time For File Name

License

Apache License

Declaration

public static String getCurrentTimeForFileName() 

Method Source Code


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

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

public class Main {
    public static String getCurrentTimeForFileName() {
        SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy_HHmmssS");
        Date timeStr = Calendar.getInstance().getTime();
        return formatter.format(timeStr);
    }/* w  w  w  .j av a2s .c om*/

    public static String getTime(Date executionTime) {
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(executionTime);
    }

    public static Date getTime(String timeInString) {

        DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
        Date date = null;

        try {

            date = dateFormat.parse(timeInString);

            // System.out.println("Date and Time: " + date);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return date;

    }
}

Related

  1. getCurrentTime(String timeFormat)
  2. getCurrentTime2MysqlDateTime()
  3. getCurrentTimeAndDate()
  4. getCurrentTimeAsNumber()
  5. getCurrentTimeAsString()
  6. getCurrentTimeForLog()
  7. getCurrentTimeForName()
  8. getCurrentTimeForUseInAFileName()
  9. getCurrentTimeInMySqlTime()