Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert UTCTimestamp to java.util.Date

Posted on 2011-03-08
13
Medium Priority
?
329 Views
Last Modified: 2012-05-11
Just small question, how to convert Date from UTCTimestamp to java.util.Date?
Thank you
0
Comment
Question by:gbcbr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 35070228
Date d = new Date(longValue) would do it, but what form is this timestamp in? What type?
0
 

Author Comment

by:gbcbr
ID: 35070294
I have original array Data in UTC format:
if (message instanceof MarketDataSnapshot) {

            incomingQuote = (MarketDataSnapshot)message;
            symbol = incomingQuote.getInstrument().getSymbol();
            double bPx = incomingQuote.getBidOpen();
            double aPx = incomingQuote.getAskOpen();
            UTCTimestamp ts = incomingQuote.getOpenTimestamp();

            try {

                if ("EUR/USD".equalsIgnoreCase(symbol.trim())) {
                    
                    BorderControl.getInstance().borderControl(bidPx,
                                                              askPx);
                    bidPx[0] = bPx;
                    eurusd_bid = String.valueOf(bidPx[0]);
                    DCC.getInstance().setEURUSD_bid(eurusd_bid);
                    askPx[0] = aPx;
                    eurusd_ask = String.valueOf(askPx[0]);
                    DCC.getInstance().setEURUSD_ask(eurusd_ask);
                    avg[0] = (bidPx[0] + askPx[0])/2;
                    avg_ts[0] = ts;
                    ChartCommander.getInstance().chartEURUSD(avg, avg_ts, outY);
                }

Open in new window

I need to send it to OHLC, but there java.util.Date format and I have error message:
Cannot cast UTCTimestamp[] to java.util.Date[].
So, before sending I have to convert it to acceptable format.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35070362
UTCTimestamp is in what API?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gbcbr
ID: 35070374
import com.fxcm.fix.UTCTimestamp;
0
 

Author Comment

by:gbcbr
ID: 35070406
I can't send .jar file
The extension of the uploaded file is not in the list of accepted extensions.
How to send it?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 35070416
Undocumented for me, so try something like

Date d = new Date(ts.getTime());
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35070440
>>How to send it?

You can't to this site - they ban the contents as well as the archive extensions. Try mailing it to me (see profile)
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1000 total points
ID: 35070584
Use
Date d = ts.toDate();

Open in new window

0
 

Author Comment

by:gbcbr
ID: 35070618
Thank you it works , even Date d = new Date(ts.getTime()); works
0
 
LVL 92

Expert Comment

by:objects
ID: 35074029
you probable don't need to convert them at all, you can probably just copy them into new array. Simpler, and avoids wasting memory.
you only need to convert when going the other way, converting a date to a timestamp
0
 

Author Comment

by:gbcbr
ID: 35074080
Unfortunately when you work, I'm sleep and vise versa
0
 
LVL 92

Expert Comment

by:objects
ID: 35074907
I have lots of student, clients and developers in different timezones.  Its a challenge, but we manage to make it work. just need to get in sync :)
0
 

Author Comment

by:gbcbr
ID: 35074940
I agree, to solve my questions I've change my standard timetable, normally I have to sleep now, but I'm still alive!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question