o19830015 2013-02-16 02:57 采纳率: 12.5%
浏览 1860

currentTimeMillis()中4小时

有个问题,如下函数,有一个名为cachetime的参数,如何设置为4小时?设置4 * 3600000

public static File getCache(String name, Context c, int cacheTime) 
{
    if (cacheTime <= 0)
        return null;
    File cache = new File(c.getCacheDir(), name);
    long now = System.currentTimeMillis();
    if (cache.exists() && (now - cache.lastModified() < cacheTime))
        return cache;
    return null;
}
  • 写回答

1条回答

  • ce_la_vie 2013-02-16 05:54
    关注
    // 4 hours * 60 (min/hour) * 60 (sec/min) * 1000 (msec/sec)
    getCache(name, c, 4 * 3600 * 1000);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?