S. M. Shahinul Islam
S. M. Shahinul Islam

Reputation: 2800

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?

Upvotes: 2

Views: 795

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

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

Upvotes: 1

Related Questions