Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Date and timezones
Date and timezones [message #936558] Mon, 08 October 2012 01:26 Go to next message
Eclipse UserFriend
Hello,

i have a feature label of type EDate which a user can set via a dialog in the properties view. The dialog also contains besides a datepicker and spinners for date and time also a combo box to set the timezone. Therefor a GregorianCalendar is instantiated with the user's selections and a Date object is returned by the method gc.getTime(). My problem is that the timezone setting is ignored, probably because java.util.Date doesn't consider timezones (although there is a deprecated method getTimezoneOffset()).No matter what I'm doing it always shows +0200 as the timezone value. If I deactivate the dialog and modify the timezone value directly in the properties view it works of course, but the user shouldn't take care of the format (yyyy-MM-dd'T'HH:mm:ss'.'SSSZ). Through debugging i found out that the convertion from Date to String is done somewhere in the EMF framework using (Simple)DateFormat. The question is do I have to implement this myself and if so,where and how can this be done?


Regards,
Rami

[Updated on: Mon, 08 October 2012 01:32] by Moderator

Re: Date and timezones [message #936645 is a reply to message #936558] Mon, 08 October 2012 03:24 Go to previous messageGo to next message
Eclipse UserFriend
Rami,

Comments below.

On 08/10/2012 7:26 AM, Rami D. wrote:
> Hello,
>
> i have a feature label of type EDate which a user can set via a dialog
> in the properties view. The dialog also contains besides a datepicker
> and spinners for date and time also a combo box to set the timezone.
> Therefor a GregorianCalendar is instantiated with the user's
> selections and a Date object is returned with the method gc.getTime().
> My problem is that the timezone setting is ignored, probably because
> java.util.Date doesn't consider timezones (although there is a
> deprecated method getTimezoneOffset()).
What do you mean by ignored? In the end, a Date is just a long value.
It doesn't record any timezone information...
> No matter what I'm doing it always shows +0200 as the timezone value.
You're expecting it to preserve the timezone? You can see that
GregorianCalendar.getTime() is just a long... This will always be
normalized to be your computer's time zone.
> If I deactivate the dialog and modify the timezone value directly in
> the properties view it works of cause, but the user shouldn't take
> care of the format (yyyy-MM-dd'T'HH:mm:ss'.'SSSZ).
Even here, I expect the timezone is not preserved. It will always be
normalized to your time zone.
> Through debugging i found out that the convertion from Date to String
> is done somewhere in the EMF framework using (Simple)DateFormat. The
> question is do I have to implement this myself and if so,where and how
> can this be done?
I think it's more of a question of expectations. I don't think you can
expect java.util.Date to preserve timezone information. It sounds
like you want something like javax.xml.datatype.XMLGregorianCalendar
which is supported by the DataTime data type in the XMLTypePackage.
>
> Regards,
> Rami
Re: Date and timezones [message #936719 is a reply to message #936645] Mon, 08 October 2012 05:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

thanks for your reply.

"You're expecting it to preserve the timezone? You can see that
GregorianCalendar.getTime() is just a long... This will always be
normalized to be your computer's time zone."

Makes definitely sense and it's exactely what i've realized, but I was confused due to the fact that in the ecore diagram I couldn't find any other data type than EDate for creating time objects.


"It sounds like you want something like javax.xml.datatype.XMLGregorianCalendar"

How can I assign an EAttribute in the ecore diagram to that type? It's not listed as an EType when opening the object selection dialog?

Regards,
Rami
Re: Date and timezones [message #936812 is a reply to message #936719] Mon, 08 October 2012 07:05 Go to previous messageGo to next message
Eclipse UserFriend
In the outline view you can use Load Resource... Unfortunately the
didn't use EMF's extended dialog for loading registered packages, so you
have to enter platform:/plugin/org.eclipse.emf.ecore/model/XMLType.ecore
as the URI and then all the data types define there will be available.

On 08/10/2012 11:05 AM, Rami D. wrote:
> Hi Ed,
>
> thanks for your reply.
>
> "You're expecting it to preserve the timezone? You can see that
> GregorianCalendar.getTime() is just a long... This will always be
> normalized to be your computer's time zone."
>
> Makes definitely sense and it's exactely what i've realized, but I was
> confused due to the fact that in the ecore diagram I couldn't find any
> other data type than EDate for creating time objects.
>
>
> "It sounds like you want something like
> javax.xml.datatype.XMLGregorianCalendar"
>
> How can I assign an EAttribute in the ecore diagram to that type? It's
> not listed as an EType when opening the object selection dialog?
>
> Regards,
> Rami
>
Re: Date and timezones [message #936838 is a reply to message #936812] Mon, 08 October 2012 07:39 Go to previous message
Eclipse UserFriend
Great! Many thanks for your help.

Regards,
Rami
Previous Topic:Set backgound color depending on model elements property
Next Topic:How to get properties element in EditPart programatically?
Goto Forum:
  


Current Time: Wed Jul 23 08:31:36 EDT 2025

Powered by FUDForum. Page generated in 0.29980 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top