Search code examples
javaandroidteechart

Change datetime format of x-axis?


I have a TChart with an area series. The area Points are mapped to datetime values. How can I change the format of the date labels on the x-axis?

This does not work:

area.add(new DateTime(timestamp), value); // Date value!
...
chart.getAxes().getBottom().getLabels().setDateTimeFormat("MMM 'yy");

Solution

  • This gives me an IllegalArgumentException:

    new DateTime(2012,1,1).toString("MMM 'yy");
    

    The comma ' in the string format argument is unnaccepted.

    As you can read here, the single quote is used to avoid interpretation. Put two single quotes to draw a single quote:

    new DateTime(2012,1,1).toString("MMM ''yy");