【问题标题】:How to set automatic file name creator according to current time?如何根据当前时间设置自动文件名创建者?
【发布时间】:2012-02-12 11:13:07
【问题描述】:

我正在用 java 创建一个记录器应用程序。我想根据当前时间设置文件名。在一个 android 应用程序中,我已经看到它像

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.
        }

在java中我应该使用什么包?或者怎么做?

【问题讨论】:

  • 你的 Recorder 是为什么平台编写的?
  • 平台是什么意思?我使用 Windows,并且该应用程序的目标是成为桌面应用程序。
  • 好吧,我有点困惑,你给了一个工作变体......对你不起作用......所以我问:)

标签: java time recorder


【解决方案1】:

Date 是一种可能,但我会使用currentTimeMillis()

【讨论】:

  • 是的,创建一个日期对象并使用符合您需要的格式。
猜你喜欢
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
  • 1970-01-01
  • 2020-07-10
  • 1970-01-01
  • 1970-01-01
  • 2011-04-27
  • 2013-10-27
相关资源
最近更新 更多