public void onTick(Instrument instrument, ITick tick) throws JFException { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String currentTime = sdf.format(tick.getTime());
Date currentTickTime = new Date(tick.getTime());
Calendar calCurrentTick = GregorianCalendar.getInstance(); calCurrentTick.setTime(currentTickTime); int yearTick = calCurrentTick.get(Calendar.YEAR); int monthTick = calCurrentTick.get(Calendar.MONTH); int dayTick = calCurrentTick.get(Calendar.DAY_OF_MONTH); int hourTick = calCurrentTick.get(Calendar.HOUR_OF_DAY); int minuteTick = calCurrentTick.get(Calendar.MINUTE); int secondTick = calCurrentTick.get(Calendar.SECOND);
Calendar calClosestTime = GregorianCalendar.getInstance(); Date d = GetClosestNextDate(tick); //print(d); calClosestTime.setTime(d); int yearClosest = calClosestTime.get(Calendar.YEAR); int monthClosest = calClosestTime.get(Calendar.MONTH); int dayClosest = calClosestTime.get(Calendar.DAY_OF_MONTH); int hourClosest = calClosestTime.get(Calendar.HOUR_OF_DAY); int minuteClosest = calClosestTime.get(Calendar.MINUTE); int second = calClosestTime.get(Calendar.SECOND);
} The print function is declared like this: private void print(Object o){ console.getOut().println(o); }
Then I downloaded tick data for 2014 and for strange reason I have the following output: 2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=22 2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=21 2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=21 2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=21
I don't know why hour is shifter in two hours. Do you have any ideas why hour is shifted in two hours? I'm especially shocked because yesterday represented code worked fine.
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on
this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control
on their content. Anyone accessing this webpage and downloading or otherwise making use of any document,
data or information found on this webpage shall do it on his/her own risks without any recourse against
Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from
the use and/or reliance on any document, data or information found on this webpage.