Tom created LANG-1684:
-------------------------

             Summary: FastDateFormat is giving wrong date when date is Feb 1
                 Key: LANG-1684
                 URL: https://issues.apache.org/jira/browse/LANG-1684
             Project: Commons Lang
          Issue Type: Bug
            Reporter: Tom


Today is Feb 1, 2022, running this block of code shows that the result is 
2022-02-32
 
{code:java}
import org.apache.commons.lang3.time.FastDateFormat;
import java.util.*;
import java.text.*;
public class MyClass {
    public static void main(String args[]) {
            FastDateFormat sdf = FastDateFormat.getInstance("YYYY-MM-DD", 
TimeZone.getDefault(), Locale.getDefault());
            Date date = new Date(System.currentTimeMillis());
            String yyyyMMdd = sdf.format(date);
System.out.println("sdf= " + sdf);
      System.out.println("yyyyMMdd= " + yyyyMMdd);
      
      Date now = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 
HH:mm:ssZ");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Europe/London"));
System.out.println(simpleDateFormat.format(now));
    }
}
{code}
sdf= FastDateFormat[YYYY-MM-DD,en_US,GMT]
yyyyMMdd= 2022-02-32
2022-02-01 17:20:57+0000



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to