Skip to content

Commit

Permalink
[anx] Fix date handling in user trade history param
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkrupinski committed Nov 24, 2014
1 parent 0e86252 commit f870475
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.math.BigDecimal;

import com.xeiam.xchange.utils.DateUtils;
import si.mazi.rescu.SynchronizedValueFactory;

import com.xeiam.xchange.ExchangeException;
Expand Down Expand Up @@ -113,8 +114,14 @@ public UserTrades getTradeHistory(Long from, Long to) throws IOException {
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws ExchangeException, IOException {

TradeHistoryParamsTimeSpan p = (TradeHistoryParamsTimeSpan) params;
return getTradeHistory(p.getStartTime(), p.getEndTime());
Long from = null;
Long to = null;
if (params instanceof TradeHistoryParamsTimeSpan) {
TradeHistoryParamsTimeSpan p = (TradeHistoryParamsTimeSpan) params;
from = DateUtils.toUnixTimeNullSafe(p.getStartTime());
to = DateUtils.toUnixTimeNullSafe(p.getEndTime());
}
return getTradeHistory(from, to);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,13 @@ public static long toUnixTime(Date time) {
return time.getTime() / 1000;
}

/**
* Convert java time to unix time long, simply by dividing by the time 1000. Null safe
* @return
*/
public static Long toUnixTimeNullSafe(Date time) {

return time == null ? null : time.getTime() / 1000;
}

}

0 comments on commit f870475

Please sign in to comment.