0

Datebox format year bug?

asked 2014-08-26 15:14:00 +0800

mhlic gravatar image mhlic
38 3

If I create a datebox like this:

<datebox format="MM/dd/yyyy HH:mm" width="200px" />

If I type in a date or select one and edit it, adding 0's to the end of the year then I end up with an incorrect year.

For instance, if I put in the date: 08/19/2014 09:04 and then add "00" to the end of the year, it turns into: 08/19/200000 09:06. Adding any two numbers (or more) to the end of the year results in the change. Obviously, that is not a valid year or format and it will not save to the database.

Has anyone experienced this and solved it?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-26 15:58:32 +0800

adamian gravatar image adamian
15 4

200000 is a valid year... it's just far, far away. It seems to be the maximum for datebox (you could have 19999 but everything over 20000 gets rounded down).

Does a contraint work for you? books.zkoss.org/wiki/ZKComponentReference/Input/Datebox#Constraint

<datebox constraint="before 20071225"/> (format dependent on the locale)

link publish delete flag offensive edit

Comments

good answer, the javadocs say something more generic: http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html ...if the number of pattern letters is 2, the year is truncated to 2 digits; otherwise it is interpreted as a number...

cor3000 ( 2014-08-27 02:13:26 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-08-26 15:14:00 +0800

Seen: 21 times

Last updated: Aug 26 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More