ParsePosition pp = new ParsePosition(pos);
DateTimeParseContext cal = f.parse(str, pp);
if (pp.getErrorIndex() >= 0) {
throw new IllegalArgumentException(str);
}
LocalTime time = cal.toCalendricalMerger().merge().get(LocalTime.rule());
int secs = time.getHourOfDay() * 60 * 60 +
time.getMinuteOfHour() * 60 + time.getSecondOfMinute();
if (pos == 1) {
secs = -secs;
}
return secs;
}