0

Datebox format/2-digit years

asked 2016-02-19 16:42:46 +0800

michaelh gravatar image michaelh
27 1

Hi,

I have a databox defined as:

<datebox id="dob"  visible="true" format="${labels.ui.locale.dateformat}" lenient="false"/>

where the label is set to MM/dd/yyyy.

When a user enters a two-digit year instead, the datebox converts it to a 4-digit year adding 1900 to the year. However, when I get the value of the database, i.e. dob.getValue(); It returns a date object with only the two digit year, like so:

DOB: Sat Aug 08 00:00:00 UTC 89

How do I keep from user's entering a 2-digit year? Or, how do I get the value displayed in the datebox, a converted 4-digit year? Is there a better way to handle dob.getValue() returning a date?

delete flag offensive retag edit

Comments

possible to recreate in a fiddle?

chillworld ( 2016-02-19 19:55:31 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-20 11:31:07 +0800

Darksu gravatar image Darksu
1991 1 4

Hello michaelh,

Probably would do it with a validator as shown below:

http://books.zkoss.org/wiki/ZKDeveloper'sReference/MVVM/Data_Binding/Validator

Check out the ShippingDateValidator example.

Best Regards,

Darksu

link publish delete flag offensive 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: 2016-02-19 16:42:46 +0800

Seen: 18 times

Last updated: Feb 20 '16

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