I am trying to generate a time series of the price data set I possess. All the times are kept as posix time, so milliseconds after 1970, so they require instantiation of a proper object that can be passed to TimeSeries. Is there any specific object that can use as a constructor parameter milliseconds and still provide info such as day/month/year etc., a bit like Java.util.Date class?
When you're populating your TimeSeries
, you can use the add(RegularTimePeriod, Number)
method.
There are several implementations of RegularTimePeriod
, including Day
and Millisecond
, depending on the structure of your data.
These are all jfreechart classes.
However, we found that in some of our applications, creating TimeSeries
of RegularTimePeriod
was memory inefficient - because you then have to create a new object for each time point in your series. As such, I found the best approach was to write our own implementation of AbstractXYDataset
to which we could add our own time series objects. I should add that we then use ChartFactory.createTimeSeriesChart(...)
, passing in our implementation of AbstractXYDataset
; this has the advantage of using a DateAxis
for the x-axis.