By default different date-time formats in action?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

By default different date-time formats in action?

Sameer Apte
Hello All,

First of all. I am impressed with efforts put by you all in Ofbiz. Really
appreciate it!
I Was feeling to get my hands dirty with it so was trying to play around
creating screens etc. especially using Person entity.

However, I am a bit confused with handling of date time formats.
Hopefully some of you can help me with it.

*==========Creating Person===========*
- I have created a menu item saying 'create'.
- When clicked user is shown a popup wherein he can enter in name and date
of birth.
- Datepicker works here and format used is 'dd/mm/yyyy HH:MI:SS' e.g.
14/07/2017 17:18:44
-The format seems to be matching the one used by operating system.
*==========Showing Person Details =================*
- Then user saves the entered values.
- Person entity gets created successfully & user is shown details of the
person created.
- On this page the date of birth is displayed using format 'yyyy-MM-dd'
e.g. 2017-07-14

The line from form doing this is
<field name="birthDate" title="Date of Birth" required-field="true"
position="1"><display default-value="${person.birthDate}"/></field>
*=========Editing Person ==========================*
- I have edit button right next person details.
- If user clicks on it I show same form that was used for creating Person
but this time with hidden party id etc.
- The form seems to be working as expected because I can change Person name
etc. without any issues.
- However 'date of birth' textbox shows date in the form of 'yyyy-MM-dd'
and datepicker button next to it is missing.
=====================================================

Now coming to the question, I was under impression that by default, ofbiz
would consistently use same date time format if I am not changing anything
anywhere. i.e. whatever it chose right at the beginning.
However it seems like when we fetch the datetime from db, due to some
reason ofbiz goes for 'yyyy-MM-dd' instead of what it did on user creation
screen i.e. 'dd/mm/yyyy HH:MI:SS'.
My guess is this also make datepicker javascript fail on edit screen which
works during creation of user.

Below is how I have included the person's birth date on the form.
*<field name="birthDate" title="Date of Birth"
required-field="true"><date-time/></field>*
It is the same form that gets used for creating as well as editing. I have
followed how it is done in Example application.

Any hint about what is it that I am missing here? Is there any single place
where I can say use 'yyyy-MM-dd HH:mi:ss' globally?

Regards,
Sameer Apte
Reply | Threaded
Open this post in threaded view
|

Re: By default different date-time formats in action?

Deepak Dixit-3
Welcome Sameer,

There are two things. One is datetime field render by freemarker, when you
create screen or form finally it will use freemarker to generate html.

In FreemarkerWorker.java we have set the default datetime formate for
freemarker template.
{code}

newConfig.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");

{code}
So all the date will be render in mentioned formate.

In case of datetime picker its an javascript (jquery ) plugin that render
the datetime picker.
and it uses the i18 to render the locale based date time formate (please
refer jquery-ui-i18n.js


Thanks & Regards
--
Deepak Dixit
www.hotwaxsystems.com
www.hotwax.co

On Tue, Jul 4, 2017 at 4:58 PM, Sameer Apte <[hidden email]> wrote:

> Hello All,
>
> First of all. I am impressed with efforts put by you all in Ofbiz. Really
> appreciate it!
> I Was feeling to get my hands dirty with it so was trying to play around
> creating screens etc. especially using Person entity.
>
> However, I am a bit confused with handling of date time formats.
> Hopefully some of you can help me with it.
>
> *==========Creating Person===========*
> - I have created a menu item saying 'create'.
> - When clicked user is shown a popup wherein he can enter in name and date
> of birth.
> - Datepicker works here and format used is 'dd/mm/yyyy HH:MI:SS' e.g.
> 14/07/2017 17:18:44
> -The format seems to be matching the one used by operating system.
> *==========Showing Person Details =================*
> - Then user saves the entered values.
> - Person entity gets created successfully & user is shown details of the
> person created.
> - On this page the date of birth is displayed using format 'yyyy-MM-dd'
> e.g. 2017-07-14
>
> The line from form doing this is
> <field name="birthDate" title="Date of Birth" required-field="true"
> position="1"><display default-value="${person.birthDate}"/></field>
> *=========Editing Person ==========================*
> - I have edit button right next person details.
> - If user clicks on it I show same form that was used for creating Person
> but this time with hidden party id etc.
> - The form seems to be working as expected because I can change Person name
> etc. without any issues.
> - However 'date of birth' textbox shows date in the form of 'yyyy-MM-dd'
> and datepicker button next to it is missing.
> =====================================================
>
> Now coming to the question, I was under impression that by default, ofbiz
> would consistently use same date time format if I am not changing anything
> anywhere. i.e. whatever it chose right at the beginning.
> However it seems like when we fetch the datetime from db, due to some
> reason ofbiz goes for 'yyyy-MM-dd' instead of what it did on user creation
> screen i.e. 'dd/mm/yyyy HH:MI:SS'.
> My guess is this also make datepicker javascript fail on edit screen which
> works during creation of user.
>
> Below is how I have included the person's birth date on the form.
> *<field name="birthDate" title="Date of Birth"
> required-field="true"><date-time/></field>*
> It is the same form that gets used for creating as well as editing. I have
> followed how it is done in Example application.
>
> Any hint about what is it that I am missing here? Is there any single place
> where I can say use 'yyyy-MM-dd HH:mi:ss' globally?
>
> Regards,
> Sameer Apte
>
Reply | Threaded
Open this post in threaded view
|

Re: By default different date-time formats in action?

Sameer Apte
Thanks Deepak.
Will explore it further from there.
Regards
Sameer Apte

On 4 Jul 2017 18:52, "Deepak Dixit" <[hidden email]> wrote:

> Welcome Sameer,
>
> There are two things. One is datetime field render by freemarker, when you
> create screen or form finally it will use freemarker to generate html.
>
> In FreemarkerWorker.java we have set the default datetime formate for
> freemarker template.
> {code}
>
> newConfig.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");
>
> {code}
> So all the date will be render in mentioned formate.
>
> In case of datetime picker its an javascript (jquery ) plugin that render
> the datetime picker.
> and it uses the i18 to render the locale based date time formate (please
> refer jquery-ui-i18n.js
>
>
> Thanks & Regards
> --
> Deepak Dixit
> www.hotwaxsystems.com
> www.hotwax.co
>
> On Tue, Jul 4, 2017 at 4:58 PM, Sameer Apte <[hidden email]> wrote:
>
> > Hello All,
> >
> > First of all. I am impressed with efforts put by you all in Ofbiz. Really
> > appreciate it!
> > I Was feeling to get my hands dirty with it so was trying to play around
> > creating screens etc. especially using Person entity.
> >
> > However, I am a bit confused with handling of date time formats.
> > Hopefully some of you can help me with it.
> >
> > *==========Creating Person===========*
> > - I have created a menu item saying 'create'.
> > - When clicked user is shown a popup wherein he can enter in name and
> date
> > of birth.
> > - Datepicker works here and format used is 'dd/mm/yyyy HH:MI:SS' e.g.
> > 14/07/2017 17:18:44
> > -The format seems to be matching the one used by operating system.
> > *==========Showing Person Details =================*
> > - Then user saves the entered values.
> > - Person entity gets created successfully & user is shown details of the
> > person created.
> > - On this page the date of birth is displayed using format 'yyyy-MM-dd'
> > e.g. 2017-07-14
> >
> > The line from form doing this is
> > <field name="birthDate" title="Date of Birth" required-field="true"
> > position="1"><display default-value="${person.birthDate}"/></field>
> > *=========Editing Person ==========================*
> > - I have edit button right next person details.
> > - If user clicks on it I show same form that was used for creating Person
> > but this time with hidden party id etc.
> > - The form seems to be working as expected because I can change Person
> name
> > etc. without any issues.
> > - However 'date of birth' textbox shows date in the form of 'yyyy-MM-dd'
> > and datepicker button next to it is missing.
> > =====================================================
> >
> > Now coming to the question, I was under impression that by default, ofbiz
> > would consistently use same date time format if I am not changing
> anything
> > anywhere. i.e. whatever it chose right at the beginning.
> > However it seems like when we fetch the datetime from db, due to some
> > reason ofbiz goes for 'yyyy-MM-dd' instead of what it did on user
> creation
> > screen i.e. 'dd/mm/yyyy HH:MI:SS'.
> > My guess is this also make datepicker javascript fail on edit screen
> which
> > works during creation of user.
> >
> > Below is how I have included the person's birth date on the form.
> > *<field name="birthDate" title="Date of Birth"
> > required-field="true"><date-time/></field>*
> > It is the same form that gets used for creating as well as editing. I
> have
> > followed how it is done in Example application.
> >
> > Any hint about what is it that I am missing here? Is there any single
> place
> > where I can say use 'yyyy-MM-dd HH:mi:ss' globally?
> >
> > Regards,
> > Sameer Apte
> >
>