I have a problem, I think that the result of this block of code should be "February", but the result is "March", what I'm doing wrong?
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
public class Calendario {
public static void main(String args[]){
Locale locale = new Locale("es","MX");
Calendar calendarTemp = new GregorianCalendar();
calendarTemp.set(Calendar.MONTH,1);
String mesTemp = calendarTemp.getDisplayName(Calendar.MONTH, Calendar.LONG, locale);
System.out.println(mesTemp);
}
}
Thanks for your help.
My guess is that February 30 is coming back as March 2.
This duplicate question has the best answer: A strange behavior from java.util.Calendar on February
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With