I'm referring to the java.util.Calendar package. I've been using Date and I'm pretty happy with it but it's been deprecated so I'd like to learn how to use Calendar.
I've read about it on Sun's website but I'm still not quite comfortable with it. All I need to do is get the current month/day/year and print it out, so if you know at least that your help is still appreciated.
How do I use Calendar in Java?
// Get calendar instance
Calendar cal = Calendar.getInstance();
int day = cal.get( Calendar.DATE);
int month = cal.get( Calendar.MONTH);
int year = cal.get( Calendar.YEAR);
Watch out for the month value though because January is 0 not 1
Set a value by
cal.set( Calendar.MINUTE, 30 );
Reply:I agree with 1st answer....
It will work...
plants
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment