Android 日历添加日期 [英] Android Calendar add day

查看:19
本文介绍了Android 日历添加日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由数据库中获取的数据填充的数组字符串.现在对于数组的每一行,我想在日历中添加一天,今天的0"行,明天的1"行,明天之后的2"行等......我创建了这段代码来控制数组中每个元素的位置,但是我如何添加天数?谢谢

I have an array String populated by data taken from the database. Now for each row of the array I want to add a day to the calendar, the line "0" day today, the line "1" tomorrow, the line "2" after tomorrow etc .. I created this code that controls the position of each element of the array, but how I add the days? thanks

Calendar prova = Calendar.getInstance();
        int size = id_op.length;
        for(int i = 0; i< size; i++){                 

        }

推荐答案

您可以只获取以毫秒为单位的时间,然后添加一天的毫秒数.

You can just get the time in milliseconds and then add a day worth of milliseconds to it.

Calendar prova = Calendar.getInstance();
        int size = id_op.length;
        for(int i = 0; i< size; i++){                 
            Long time = prova.getTimeInMillis();
            time = time + 86400000;
            prova.setTimeInMillis(time);           
        }

这篇关于Android 日历添加日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆