Reputation: 5166
Although i read a lot about the calendar and gregoriancalendar, still some complications arise. Which is better or what can you recommend to use? I cant not figure out the difference.
GregorianCalendar gc = (GregorianCalendar) GregorianCalendar.getInstance();
or
Calendar c = Calendar.getInstance();
what do you say?
Upvotes: 4
Views: 7299
Reputation: 4266
If you need to manipulate some dates, it's easier to use GragorianCalendar!
Upvotes: -1
Reputation: 769
If you don't need work with other kind of calendars, use GregorianCalendar. But, if you want more frexibility, then use Calendar.
You can read this mail-archive where this topic is discussed.
Only one remark:
In order to have less cast problems, it's better declare a Calendar object and initialize as GregorianCalendar. Here's an example: Calendar gregorian = new GregorianCalendar();
Upvotes: 2
Reputation: 4181
Calendar is an abstract class, the getInstance method returns one of is implementations depending on the default Locale of your system. This means that if you are using an European or American locale, you'll be using the Gregorian Calendar anyway.
In any case, you should always try to use the Implementation according to the area you are, if the application is in Japan, you may have some problems, because the Japanese calendar is a bit different, for example
You can check it in the Android documentation: here
Upvotes: 8