【问题标题】:Add single unit of time to timestamp for use in Blackberry application将单个时间单位添加到时间戳以在 Blackberry 应用程序中使用
【发布时间】:2010-01-18 06:24:30
【问题描述】:

如何将单个时间单位添加到时间戳,就像 Java“日历”类的“添加方法”但使用 Blackberry API 集 任何人都可以帮我提供源代码吗?

【问题讨论】:

    标签: blackberry java-me time


    【解决方案1】:

    您仍然可以在 BlackBerry 中使用 Calendar

    class Scr extends MainScreen {
        public Scr() {
            Date date = new Date(System.currentTimeMillis());
            add(new LabelField("now:"));
            add(new LabelField(date.toString()));
            add(new LabelField("past month:"));
            add(new LabelField(addDateTime(date, Calendar.MONTH, 1).toString()));
        }
    
        public Date addDateTime(Date date, int field, int addValue) {
            Calendar c = Calendar.getInstance();
            c.setTime(date);
            int value = c.get(field);
            c.set(field, value + addValue);
            return c.getTime();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-09-21
      • 2021-03-18
      • 1970-01-01
      • 1970-01-01
      • 2018-07-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      相关资源
      最近更新 更多