0

Problem with date visualization

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

gammaGroup gravatar image gammaGroup
31

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

Comments

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
0

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

gammaGroup gravatar image gammaGroup
31

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

cor3000 gravatar image cor3000
4671 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}"/>
  </listhead>
  <template name="model" var="r">
    <listitem>
      <listcell
          label="@load(r.contract.startDate)@converter('formatedDate',format='dd/MM/YYYY')"/>
      <listcell
          label="@load(r.contract.endDate)@converter('formatedDate',format='dd/MM/YYYY')"/>
    </listitem>
  </template>
</listbox>

thanks

link publish delete flag offensive edit
0

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

cor3000 gravatar image cor3000
4671 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.

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

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

Follow
2 followers

RSS

Stats

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

Seen: 9 times

Last updated: Sep 02

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