OHLCPlugInView.java: fix bug in interval parsing. test.
This commit is contained in:
@ -34,9 +34,9 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
private static final Logger log = LoggerFactory.getLogger(OHLCPlugInView.class);
|
||||
private static final int LATE_EVENT_SLACK_SECONDS = 5;
|
||||
private static final PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
|
||||
.appendDays().appendSuffix("d ")
|
||||
.appendHours().appendSuffix("h ")
|
||||
.appendMinutes().appendSuffix("m ")
|
||||
.appendDays().appendSuffix("d")
|
||||
.appendHours().appendSuffix("h")
|
||||
.appendMinutes().appendSuffix("m")
|
||||
.appendSeconds().appendSuffix("s")
|
||||
.toFormatter();
|
||||
|
||||
@ -78,7 +78,15 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
private Duration parseInterval(ExprNode interval) {
|
||||
ExprEvaluator evaluator = interval.getForge().getExprEvaluator();
|
||||
String intervalStr = (String)evaluator.evaluate(null, true, agentContext);
|
||||
return periodFormatter.parsePeriod(intervalStr).toStandardDuration();
|
||||
return parseInterval(intervalStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time period specified by the given string.
|
||||
*/
|
||||
public static Duration parseInterval(String interval) {
|
||||
interval = interval.replaceAll("\\s+","");
|
||||
return periodFormatter.parsePeriod(interval).toStandardDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user