1,105,594 Community Members

How to process TimeStamp in chartapi.finance.yahoo.com???

Member Avatar
zac_mathews
Newbie Poster
3 posts since Feb 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi
I am a J2ME developer I am new to Dani Web.
I am using chartapi.finance.yahoo.com to calculate and display chart.
My questions is how to convert TIMESTAMP value to a Java Date or Calendar Object ?.....


For Eg: URL GIVEN BELOW

http://chartapi.finance.yahoo.com/instrument/1.0/aapl/chartdata;type=quote;range=1d/csv/

Its output will be

uri:/instrument/1.0/aapl/chartdata;type=quote;range=1d/csv/
ticker:aapl
unit:MIN
timezone:EST
gmtoffset:-18000
previous_close:199.2300
Timestamp:1265207400,1265230800
labels:1265209200,1265212800,1265216400,1265220000,1265223600,1265227200,1265230800
values:Timestamp,close,high,low,open,volume
close:194.7100,200.1600
high:194.9800,200.2000
low:194.4200,200.0300
open:194.7599,200.1600
volume:7100,678600
1265207400,195.2600,195.4000,195.1000,195.1700,273700
1265207460,195.0400,195.2700,194.9200,195.2300,127500
.........


How to convert values hilighted in RED to Date or calendar Object?...

I Tried this

Calendar cal=Calendar.getInstance();
cal.setTime(new Date(1265207400));

But unfortunatly cal value is set to 15/Jan/1970 15:26:47.:ooh:

Danni Gurus please help....:|

Thanks in Advance

Zac

Member Avatar
~s.o.s~
Failure as a human
10,399 posts since Jun 2006
Reputation Points: 2,496 [?]
Q&As Helped to Solve: 992 [?]
Skill Endorsements: 72 [?]
Administrator
Featured
 
1
 

> My questions is how to convert TIMESTAMP value to a Java Date
> or Calendar Object ?.....

It seems that the Timestamp here refers to the Unix timestamp (which is the number of seconds elapsed since January 1, 1970 (midnight UTC/GMT). This is in contrast with the way Java timestamp works which is considered to be the number of milliseconds elapsed since January 1, 1970 (midnight UTC/GMT). Multiplying the returned value with 1000 should do the trick here.

Also, ensure that you don't fall in the trap of truncation while multiplying those values.

Date d = new Date(1265207400 * 1000); //is different from
Date d = new Date(1265207400 * 1000L); // or
Date d = new Date(1265207400000);

In case you are still wondering why, in the first declaration the integer result of 1265207400 * 1000 which is 1966688416 and not 1265207400000 , is passed to the Date constructor leading to erroneous results.

> Thanks in Advance

HTH

Question Answered as of 4 Years Ago by ~s.o.s~
Member Avatar
zac_mathews
Newbie Poster
3 posts since Feb 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

THANK YOU VERY MUCH.....
ITS WORKING...... I AM SO HAPPY.....

I have posted this same issue in YDN they were not able to answer this issue......

Thanks a lot.....

Zac

Member Avatar
~s.o.s~
Failure as a human
10,399 posts since Jun 2006
Reputation Points: 2,496 [?]
Q&As Helped to Solve: 992 [?]
Skill Endorsements: 72 [?]
Administrator
Featured
 
0
 

THANK YOU VERY MUCH.....
ITS WORKING...... I AM SO HAPPY.....

You are welcome, but please do not to use red/bold text since it hurts the eyes.

I have posted this same issue in YDN they were not able to answer this issue......

Then you should post this solution or at least a link to this thread in your YDN thread to help those who end up facing a similar issue. :)

Member Avatar
zac_mathews
Newbie Poster
3 posts since Feb 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Then you should post this solution or at least a link to this thread in your YDN thread to help those who end up facing a similar issue. :)

I already done that on the same day ..

Check this out... :)

http://developer.yahoo.net/forum/index.php?showtopic=4457

(Warning:: lots of bright colors and bold fonts used in YDN ...:icon_cool:.. goggles adviced....I will avoid them next time..:))

Thanks again....

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: