Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:50+00:00 2026-06-18T12:33:50+00:00

Using the DateAxis it works fine: // From: 2/5/13 02:00:00 PM (+1), To: 2/5/13

  • 0

Using the DateAxis it works fine:

// From: 2/5/13 02:00:00 PM (+1), To: 2/5/13 03:00:00 PM (+1)
// Configuring dataset
Timezone tz = new SimpleTimeZone(1, "Test");
TimeSeriesCollection dataset = new TimeSeriesCollection(tz);
TimeSeries timeSeries = new TimeSeries("Series1");
...
timeSeries.add(new Millisecond(new Date(timestamp1), tz, locale), value1);
timeSeries.add(new Millisecond(new Date(timestamp2), tz, locale), value2);
timeSeries.add(new Millisecond(new Date(timestamp3), tz, locale), value3);
...
// Setting axis timezone
((DateAxis) chart.getXYPlot().getDomainAxis()).setTimeZone(tz);
((DateAxis) chart.getXYPlot().getDomainAxis()).setRange(new DateRange(
           from, to), true, true);

DateAxis Chart

But when I try to do the same with the PeriodAxis it displays a incorrect time zone. Looks like it is getting the timezone from my computer (-3).

// From: 2/5/13 02:00:00 PM (+1), To: 2/5/13 03:00:00 PM (+1)
// Configuring dataset
Timezone tz = new SimpleTimeZone(1, "Test");
TimeSeriesCollection dataset = new TimeSeriesCollection(tz);
TimeSeries timeSeries = new TimeSeries("Series1");
...
timeSeries.add(new Millisecond(new Date(timestamp1), tz, locale), value1);
timeSeries.add(new Millisecond(new Date(timestamp2), tz, locale), value2);
timeSeries.add(new Millisecond(new Date(timestamp3), tz, locale), value3);
...
// Setting periodAxis
PeriodAxis periodaxis = new PeriodAxis("");

periodaxis.setFirst(new Millisecond(new Date(from), tz));
periodaxis.setLast(new Millisecond(new Date(to), tz));

periodaxis.setTimeZone(tz);

periodaxis.setRange(new DateRange(from, to), true, true);
periodaxis.setAutoRangeTimePeriodClass(Second.class);
PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(
        org.jfree.data.time.Minute.class, new SimpleDateFormat("mm"));
aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(
        org.jfree.data.time.Hour.class, new SimpleDateFormat("HH"));
periodaxis.setLabelInfo(aperiodaxislabelinfo);

chart.getXYPlot().setDomainAxis(periodaxis);

Period Axis Chart

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:33:51+00:00Added an answer on June 18, 2026 at 12:33 pm

    Found two ways to solve this problem:

    Frist

    Setting the timezone on the SimpleDateFormat:

    ...
    SimpleDateFormat dfMin = new SimpleDateFormat("mm");
    dfMin.setTimeZone(tz); // Setting timezone
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(
            org.jfree.data.time.Minute.class, dfMin);
    SimpleDateFormat dfHour = new SimpleDateFormat("mm");
    dfHour.setTimeZone(tz); // Setting timezone
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(
            org.jfree.data.time.Hour.class, dfHour);
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    ...
    

    Second

    Also reported this as a bug, IMO the axis must respect the periodaxis.setTimeZone(tz); instruction. This line should be added to PeriodAxis.java:

    885        while (p.getFirstMillisecond() <= axisMax) {
    886            float x = (float) valueToJava2D(p.getMiddleMillisecond(), dataArea,
    887                    edge);
    888            DateFormat df = this.labelInfo[band].getDateFormat();
    
                   df.setTimeZone(timeZone); // Missing timezone setting
    
    889            String label = df.format(new Date(p.getMiddleMillisecond()));
    890            long first = p.getFirstMillisecond();
    891            long last = p.getLastMillisecond();
    892            if (last > axisMax) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I am new to using JFreeChart and I'm sure there is a simple solution
(using jquery or just js) Is it possible to add script to an iframe
I'm using jFreeChart 1.0.14. I have graph with a horizontal DateAxis . And I'm
Using php's DOMDocument->LoadHTMLFile('test.html'); keeps on returning an error to me, reporting for an error
using this code: Java Server side: ... out = new PrintWriter(this.client.getOutputStream(), true); ... public
Using Android NDK is it possible (from native C-code) to get a list of
Using JQuery,Is there any possible to capture images/scanned documents from digital Camera/Scanner Connected to
Using Joomla! 3.0 (Or 2.5, whatever works best), I'm needing to create a system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.