开发者

roll() and add() [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete,开发者_StackOverflow overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

what is the diference between roll() and add() in java ?

/*this the class that i wanted to see if i can use add in place of roll . and thank you */

    mydate.roll(Calendar.MINUTE, true);
    int nextminutes = mydate.get(Calendar.MINUTE);
    int nexttseconds = mydate.get(Calendar.SECOND);
    while(count<1000000){
        System.out.println(sentence);
        GregorianCalendar now = new GregorianCalendar();

    if(mydate.get(Calendar.MINUTE)>= nextminutes){
        break;
    }   
    }
    count++;
    System.out.println("i wrote the sentence"+count+"time.");


}

}


If you're working on a calendar:

"Calendar.roll changes a specific unit and leaves 'larger' ( in terms of time - month is 'larger' than day) units unchanged. The API example is that given a date of August 31, 1999, rolling by (Calendar.MONTH, 8) yields April 30, 1999. That is, the DAY was changed to meet April's maximum, but the 'larger' unit, YEAR, was unchanged.

Calendar.add will cause the next 'larger' unit to change, if necessary. That is, given a date of August 31, 1999, add(Calendar.MONTH, 8) yields April 30, 2000. add() also forces a recalculation of milliseconds and all fields. "

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜