Convert UTCTimestamp to java.util.Date

Just small question, how to convert Date from UTCTimestamp to java.util.Date?
Thank you
gbcbrAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Undocumented for me, so try something like

Date d = new Date(ts.getTime());
0
 
CEHJCommented:
Date d = new Date(longValue) would do it, but what form is this timestamp in? What type?
0
 
gbcbrAuthor Commented:
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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
CEHJCommented:
UTCTimestamp is in what API?
0
 
gbcbrAuthor Commented:
import com.fxcm.fix.UTCTimestamp;
0
 
gbcbrAuthor Commented:
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
 
CEHJCommented:
>>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
 
CEHJConnect With a Mentor Commented:
Use
Date d = ts.toDate();

Open in new window

0
 
gbcbrAuthor Commented:
Thank you it works , even Date d = new Date(ts.getTime()); works
0
 
objectsCommented:
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
 
gbcbrAuthor Commented:
Unfortunately when you work, I'm sleep and vise versa
0
 
objectsCommented:
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
 
gbcbrAuthor Commented:
I agree, to solve my questions I've change my standard timetable, normally I have to sleep now, but I'm still alive!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.