作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Jfreechart。我有这样的代码:
TimeSeries t1 = new TimeSeries("EUR/GBP");
t1.add(new Day(4, MonthConstants.JANUARY, 2001), new Double(1.5807));
但是我从 SQL 查询中得到了 String
。 TimeSeries 仅接受 RegularTimePeriod
或 TimeSeriesDataItem
。
请告诉我如何将 String
转换为 RegularTimePeriod
。
提前致谢。
最佳答案
首先,您可以通过使用 SimpleDateFormat 解析 mysql 日期字符串来获取 Date 对象,然后使用带有 Date 参数的构造函数创建 RegularTimePeriod。
基本上(假设 mysqlDateStr 是来自 mysql 查询的字符串):
SimpleDateFormat standardDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// (Define your formatter only once, then reuse)
Date myDate = standardDateFormat.parse(mysqlDateStr);
// (you may want to catch a ParseException)
t1.add(new Day(myDate), new Double(1.5807));
关于java - java中如何将字符串转换为RegularTimePeriod?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/421020/
我可以使用 TimeSeries使用 JFreeChart 绘制 1 分钟的数据。我想知道是否可以轻松绘制其他时间间隔,例如 5 分钟或 15 分钟等? RegularTimePeriod 似乎只有
我是一名优秀的程序员,十分优秀!