本文共 928 字,大约阅读时间需要 3 分钟。
jfreechart日期是为默认系统所在地区语言及格式,当我需要把web放在中国,而访问的是在美国时,看到日期文字框则是中文的。因此需要修改日期格式化对象。
在org.jfree.chart.axis包中有这么一个DateAxis类,它是用来格式化日期的,因为我们把它所有有关日期的地区及时区修改为美国即可,特别是在以下方要修改的。
/** The default date tick unit. */ public static final DateTickUnit DEFAULT_DATE_TICK_UNIT = new DateTickUnit( DateTickUnit.DAY, 1, new SimpleDateFormat("MM/dd/yy", Locale.US));
这里有7个格式化对象。很好找的,我修改时,却找了半天,把它记下。
// date formatters DateFormat f1 = new SimpleDateFormat("HH:mm:ss.SSS", Locale.US); DateFormat f2 = new SimpleDateFormat("HH:mm:ss", Locale.US); DateFormat f3 = new SimpleDateFormat("HH:mm", Locale.US); DateFormat f4 = new SimpleDateFormat("d-MMM, HH:mm", Locale.US); DateFormat f5 = new SimpleDateFormat("d-MMM", Locale.US); DateFormat f6 = new SimpleDateFormat("MMM-yyyy", Locale.US); DateFormat f7 = new SimpleDateFormat("yyyy", Locale.US);
时区设置
public DateAxis(String label) { this(label, TimeZone.getTimeZone("America/Los_Angeles")); }
转载地址:http://zgbhb.baihongyu.com/