android - 如何根据一个周期遍历一个日历
阿神
阿神 2017-04-17 16:01:32
0
2
680

具体的情况是这样的,目标是做一个日历,想在某个周期(比如20天)的日子里显示固定的文字(比如上班)

我暂时制作出了一个周期的,不知道按这个周期来有什么好的办法,需要涉及到计算年月日的话比较麻烦。。

阿神
阿神

闭关修行中......

reply all(2)
黄舟

Does the original poster want to ask how to calculate the year, month and day conveniently?

Recommend a java date library: http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTime.html

Just keep calling functions like plusDays, minusDays. It's very convenient. You don't need to deal with various boundary conditions such as leap year or normal year, 30 days or 31 days.

大家讲道理

I did it myself. . It turns out it’s not that difficult
Just write a tool class

public static int DateDifferentSum(Date date1,Date date2){
        calendar1.setTime(date1);
        calendar2.setTime(date2);
        int dayCount = (int) ((calendar1.getTimeInMillis()-calendar2.getTimeInMillis())/(1000*3600*24));
        return dayCount;
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template