[
https://issues.apache.org/jira/browse/OLINGO-247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13976779#comment-13976779
]
Michael Bolz commented on OLINGO-247:
-------------------------------------
Hi,
as Chandan mentioned the default time zone for Olingo is UTC.
So in your second example you create a {{Calendar}} with {{IST}} as time zone
which than is serialized into a Edm.DataTime in default UTC time.
So your {{Apr 16 14:57:36 IST 2014}} results in {{2014-04-16T09:27:36.495}} in
UTC time zone.
If you want want to use and print the created calendar instance in UTC you have
to create and set the date with the time zone:
{code}
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
cal.setTime(new Date());
{code}
and (on client side) use a {{DateFormat}} instance for creation of the correct
data string:
{code}
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.LONG);
df.setCalendar(cal);
System.out.println("DF:\n" + df.format(cal.getTime()));
{code}
Date handling with time zones in Java and especially in combination with
databases is a little bit tricky.
Kind regards,
Michael
> Date Time and Time Zone Issue
> -----------------------------
>
> Key: OLINGO-247
> URL: https://issues.apache.org/jira/browse/OLINGO-247
> Project: Olingo
> Issue Type: Question
> Components: odata2-core
> Affects Versions: V2 1.2.0
> Reporter: Selvaratnam Ruckman Colins
> Assignee: Chandan V.A
> Priority: Blocker
>
> I am using MySql data base to store Odata information,One of my table has
> date column with value as "2013-04-02" and In my JPA entity I map this column
> to Java Calender as follow
> @Column(name = "date",columnDefinition="DATE")
> @Temporal(TemporalType.DATE)
> private Calendar tradingDate
> But when i fetch these entities using Odata the date comes as
> <d:TradingDate>2013-04-01T18:30:00</d:TradingDate>
> In fact All dates in the table come with some reduction value which may be
> Time Zone offset & My local time zone is IST(+5.30)
> I think the date is been converted to GMT or UTC by olingo, How do i resolve
> this issue?
--
This message was sent by Atlassian JIRA
(v6.2#6252)