Search code examples
javatimerecorder

How to set automatic file name creator according to current time?


I am creating a recorder application in java. I want to set the file names according to the current time. In an android application I have seen it like

import android.text.format.Time;

public CallRecorder(String filename,int sample_rate)
    {
        if (filename == null)
        {
            Time t = new Time();
            t.setToNow();
            filename = t.format2445(); // Create filename from current date.
        }

In java what package should I use? or how to do that?


Solution

  • Date is one possiblility, though I'd use the currentTimeMillis().