[英]From jFreeChart Millisecond to java.util.Date
Regarding jFreeChart's Millisecond , 关于jFreeChart的毫秒 ,
How can I get a java.util.Date object from a Millisecond
instance? 如何从Millisecond
实例中获取java.util.Date对象?
From the docs, it only seems possible to subtract the milliseconds within Millisecond
. 从文档中,似乎只能减去毫秒内的Millisecond
。
Since a Millisecond
object is constructed like so: 由于Millisecond
对象的构造如下:
Millisecond ms = new Millisecond(
millisec,
second,
minute,
hour,
day,
month,
year);
I should be able to extract a valid Date
object as well. 我也应该能够提取一个有效的Date
对象。
I need a Date
object that gives back the exact time up to the millisecond accurate. 我需要一个Date
对象,它可以准确地返回精确到毫秒的精确时间。
Does .getStart()
provide this? .getStart()
是否提供此功能?
[ANSWER] : YES [答案] :是的
Millisecond is like any other RegularTimePeriod in JFreeChart, so you can just 毫秒就像JFreeChart中的任何其他RegularTimePeriod一样,所以你可以
Date d = ms.getStart();
or 要么
Date d = ms.getEnd();
depending on whether you want a date referring to the beginning or the end of your millisecond (same value either way). 取决于你是否想要一个参考毫秒开头或结尾的日期(无论哪种方式都是相同的值)。
See The JFreeChart API for more info. 有关详细信息,请参阅JFreeChart API 。
EDIT: Adding code here since comments kill formatting: 编辑:这里添加代码,因为评论杀死格式:
Millisecond ms = new Millisecond();
System.out.println(ms.getStart().getTime());
System.out.println(ms.getEnd().getTime());
will print the same millisecond twice. 将两次打印相同的毫秒。
据我所知, Millisecond
类表示一毫秒的时间段,我假设从RegularTimePeriod
继承的getStart
和getEnd
方法返回(几乎)与您正在寻找的Date
相同的Date
。
(my answer was late) Perhaps you could use this code: (我的回答很晚)也许你可以使用这段代码:
java.util.Date date = new java.util.Date(freeMillis.getMillisecond());
edit: scrap that, freeMillis.getMillisecond() returns just a millisecond part. 编辑:废弃,freeMillis.getMillisecond()只返回毫秒部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.