Related questions
First day of next month with java Joda-Time
How would you rewrite the method below, which returns the first day of next month, with the org.joda.time package in Joda-Time?
public static Date firstDayOfNextMonth() {
Calendar nowCal = Calendar.getInstance();
int month = nowCal.get(Calendar.MONTH) + 1;
int year = nowCal.…
In Java, how to get strings of days of week (Sun, Mon, ..., Sat) with system's default Locale (language)
The simplest way:
String[] namesOfDays = new String[7] {
"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
};
This method does not use Locale. Therefore, if the system's language is not English, this method does not work properly.
Using Joda time, we can do …
Why dec 31 2010 returns 1 as week of year?
For instance:
Calendar c = Calendar.getInstance();
DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
c.setTime( sdf.parse("31/12/2010"));
out.println( c.get( Calendar.WEEK_OF_YEAR ) );
Prints 1
Same happens with Joda time.
:)