将多个日期设置为日历

时间:2015-01-17 10:19:06

标签: java android android-calendar

我是新手在java中使用日历。我想设置多个日期到我的日历(对于Android),但我做错了因为我只看最后一个。

我试过这样:

 Calendar cal = Calendar.getInstance();
                cal.set(Calendar.YEAR, 2015);
                cal.set(Calendar.MONTH, Calendar.MARCH);
                cal.set(Calendar.DAY_OF_MONTH, 30);
                cal.set(Calendar.YEAR, 2015);
                cal.set(Calendar.MONTH, Calendar.MARCH);
                cal.set(Calendar.DAY_OF_MONTH, 20);
Date dateRepresentation = cal.getTime();

就像这样:

Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, 2015);
        cal.set(Calendar.MONTH, Calendar.MARCH);
        cal.set(Calendar.DAY_OF_MONTH, 30);

        Calendar cal2 = Calendar.getInstance();
        cal2.set(Calendar.YEAR, 2015);
        cal2.set(Calendar.MONTH, Calendar.MARCH);
        cal2.set(Calendar.DAY_OF_MONTH, 20);

        Date dateRepresentation = cal.getTime();
        Date dateRepresentation2 = cal2.getTime();

有人可以帮助我吗?谢谢

0 个答案:

没有答案