Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

yoda time seems not to be affected:

  * Y       year of era (>=0)            year          1996
  * x       weekyear                     year          1996
  * y       year                         year          1996


Clearly, Yoda has 900 years of experience dealing with datetime bugs.


If you mean Joda time, then "xxxx" is also affected (which is correct behavior):

  public static void main(String[] args) {
    long now = System.currentTimeMillis();
    System.out.println("YYYY: " + DateTimeFormat.forPattern("YYYY").print(now));
    System.out.println("yyyy: " + DateTimeFormat.forPattern("yyyy").print(now));
    System.out.println("xxxx: " + DateTimeFormat.forPattern("xxxx").print(now));	
  }
prints

  YYYY: 2014
  yyyy: 2014
  xxxx: 2015


Nobody will use xxxx by accident, so it's not 'affected' by any problem/confusion, it's just there doing what the developer intended.


Y and y are only different for BC dates in the Gregorian calendar, so using the incorrect one generally isn't going to cause problems.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: