Solved

Convert UTCTimestamp to java.util.Date

Posted on 2011-03-08
13
326 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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 250 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 250 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

737 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