private TimeSeries convertToJFCTimeSeries( boolean interpolate, String name, TimeAddressable<Double> ts) throws KeyedException { Constructor<? extends RegularTimePeriod> constructor = getPeriodConstructor(ts.getTimeDomain()); TimeSeries timeSeries = new TimeSeries(name); for (Observation<Double> obs : ts) { Double value = obs.getValue(); if (ts.isMissing(value)) { if (interpolate) continue; } Date date = JavaDateUtil.toJavaDate(obs.getTime()); RegularTimePeriod period = null; try { period = constructor.newInstance(date); } catch (Exception e) { throw K.JFC_PERIOD_ERR.exception(e, date.toString()); } timeSeries.add(period, value); } return timeSeries; }