Date and TimeZone

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rod

Date and TimeZone

Post by rod » Thu Dec 13, 2001 3:24 pm

sorry if my question sounds stupid but i m new to jfreechart....
I m trying to generate a chart with DateTimeAxis :

Object[][][] array = ...
DefaultXYDataset ds = new DefaultXYDataset(array);
ds.setSeriesNames(new String[] {"..."});
DateAxis timeAxis = new HorizontalDateAxis(xAxisLabel);
timeAxis.setAutoTickValue(false);
timeAxis.setTickUnit(new DateUnit(Calendar.HOUR_OF_DAY, 3));
timeAxis.getTickLabelFormatter().applyPattern("H:mm z");
NumberAxis valueAxis = new VerticalNumberAxis(yAxisLabel);
valueAxis.setAutoRangeIncludesZero(false); // override default
XYPlot plot = new XYPlot(timeAxis, valueAxis);
plot.setXYItemRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES));
JFreeChart chart = new JFreeChart(ds, plot, /*title*/null, JFreeChart.DEFAULT_TITLE_FONT, true);

My Problem is with the formatting of the date.
i d like to be able to change the timezone used to display the date on the horizontal axis.
Is there a way to do that ?
thanks
rodolphe

with

David Gilbert

RE: Date and TimeZone

Post by David Gilbert » Thu Dec 13, 2001 4:19 pm

Hi Rodolphe,

If you use the full version of the constructor for DateAxis you can specify the SimpleDateFormat object to use. Unfortunately I didn't write accessor methods for it, so the only other way to change it is to modify the code directly.

I'm going to rewrite some of that code soon, so I'll try to think up a better scheme...

Regards,

DG.

rod

RE: Date and TimeZone

Post by rod » Fri Dec 14, 2001 9:30 am

well, i eventually found an easy way to do it :
(i was looking at SimpleDateFormat but the needed method was in DateFormat...)

DateAxis timeAxis = new HorizontalDateAxis(xAxisLabel);
timeAxis.getTickLabelFormatter().applyPattern("H:mm");
timeAxis.getTickLabelFormatter().setTimeZone(TimeZone.getTimeZone(timezone));

so it now works fine for me !!!!
great package really

Locked