0

I am plotting a linechart with JFreeChart. X axis of the linechart should be time and I want to get this time as a string like "08:20:20,19". When I am trying to convert LocalTime to RegularTimePeriod, it does not let me to do that. Is there any way to convert LocalTime to Regular time period or is there any way to get time as a String? I use timeSeries because only timeSeries get regularTimePeriod. To explain the sitauation crystal clear here is a code :

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss,SS", Locale.ENGLISH);
String a = "08:20:20,19";
LocalTime localTime = LocalTime.parse(a);
try{
t = new Millisecond(simpleDateFormat.parse(a));}
catch(ParseException e){
e.printStackTrace();
}
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
shnnens
  • 11
  • 2
  • 1
    What does this have to do with `simpledateformat`? Wouldn't `jfreechart` be a more useful tag, assuming it's the JFreeChart `RegularTimePeriod` you're trying to convert to? It would really help if you'd give a concrete example of what you're trying to do, as it's not clear to me that they're comparable concepts. – Jon Skeet Mar 09 '22 at 11:53
  • I am trying to get time from a data as a string in X axis of linechart. How can i do that in JFreeChart? – shnnens Mar 09 '22 at 11:58
  • 1
    Please edit the question to clarify it, rather than adding clarifying comments. – Jon Skeet Mar 09 '22 at 12:01
  • `LocalTime` lacks the zone information required by `RegularTimePeriod`; use `Instant` as suggested [here](https://docs.oracle.com/javase/tutorial/datetime/iso/legacy.html). – trashgod Mar 09 '22 at 14:04

0 Answers0