Problem with date visualization

asked 2019-08-27 19:59:04 +0800

gammaGroup gravatar image gammaGroup

Hi, there, we have a strange problem with the grid display of the dates 30/12/2019 and 31/12/2019 which are displayed respectively as 30/12/2020 and 31/12/2020. On the database the data are saved correctly with the year 2019, and also in the datebox is selected the correct date. What can be done to correct this problem?

Thank you

delete flag offensive retag edit


Can you please explain what you mean by "grid display of the dates". Ideally can you provide some simplified zul code reproducing the issue? (e.g. on http://zkfiddle.org/) Did you already try a newer Zk version maybe this issue had been fixed in a later version after 7.0.2

cor3000 ( 2019-08-28 15:03:13 +0800 )edit

I increased your karma so you can post links.

cor3000 ( 2019-08-28 15:07:42 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-08-28 15:46:45 +0800

gammaGroup gravatar image gammaGroup

updated 2019-08-29 12:09:29 +0800

cor3000 gravatar image cor3000
5364 2 7
ZK Team

link text

Hi, To explain, I put a stamp in the link. I have not tried to update, because I am not authorized to do so, I should ask permission from my superior. It sounds stupid but here it works that way.

<listbox model="@load(vm.resources)" selectedItem="@bind(vm.selected)"  
         span="true"  style="margin:1px 0px" mold="paging" pageSize="10" 
         vflex="1" height="100%" onSelect="@command('selectResource')" >
  <listhead sizable="true">
    <listheader label="${labels.start_date}"/>
    <listheader label="${labels.end_date}"/>
  <template name="model" var="r">


link publish delete flag offensive edit

answered 2019-09-02 14:41:30 +0800

cor3000 gravatar image cor3000
5364 2 7
ZK Team

Thanks for the code reproducing the problem, now I can (and you'll as well) clearly see the root cause. The problem is not within ZK but the date format pattern you specified:

@converter('formatedDate', format='dd/MM/YYYY')

According to the javadocs on SimpleDateFormat (which ZK uses to format a date) the letter 'Y' (upper case) stands for the for the YEAR in regard with the calendar week. Since Weeks are not aligned with year ends, there's always a chance for an overlap.

Instead you need to use the lower case 'y' for the correct year associated with a day.


I assume this will solve your issue.

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




Asked: 2019-08-27 19:59:04 +0800

Seen: 9 times

Last updated: Sep 02 '19

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