@Test public void testParseImprecise() { IntervalOfTime interval = formatter.parseInterval("19750723"); assertEquals(INTERVAL, interval); }
public IntervalOfTime parseInterval(String text) { if (text == null || text.length() == 0) return null; if (intervalForm) { boolean lowClosed; boolean highClosed; if (text.startsWith("[")) { lowClosed = true; } else if (text.startsWith("]")) { lowClosed = false; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } if (text.endsWith("[")) { highClosed = false; } else if (text.endsWith("]")) { highClosed = true; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } int semicolon = text.indexOf(INTERVAL_FORM_SEPARATOR); if (semicolon == -1) throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); return create(text.substring(1, semicolon), text.substring(semicolon + INTERVAL_FORM_SEPARATOR.length(), text.length() - 1), lowClosed, highClosed); } else { int doubleDots = text.indexOf(DEFAULT_SEPARATOR); if (doubleDots == -1) { if (HL7DateTimeFormat.HL7_PATTERN.matcher(text).matches()) { return HL7DateTimeFormat.parse(text).promote(); } else if (RelativeDateTimeFormat.TODAY_PATTERN.matcher(text).matches()) { return IntervalOfTime.today().toClosed(); } else { return create(text, "Today", true, true); } } else { return create(text.substring(0, doubleDots), text.substring(doubleDots + DEFAULT_SEPARATOR.length()), true, true); } } }
IntervalOfTimeFormatter { public IntervalOfTime parseInterval(String text) { if (text == null || text.length() == 0) return null; if (intervalForm) { boolean lowClosed; boolean highClosed; if (text.startsWith("[")) { lowClosed = true; } else if (text.startsWith("]")) { lowClosed = false; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } if (text.endsWith("[")) { highClosed = false; } else if (text.endsWith("]")) { highClosed = true; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } int semicolon = text.indexOf(INTERVAL_FORM_SEPARATOR); if (semicolon == -1) throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); return create(text.substring(1, semicolon), text.substring(semicolon + INTERVAL_FORM_SEPARATOR.length(), text.length() - 1), lowClosed, highClosed); } else { int doubleDots = text.indexOf(DEFAULT_SEPARATOR); if (doubleDots == -1) { if (HL7DateTimeFormat.HL7_PATTERN.matcher(text).matches()) { return HL7DateTimeFormat.parse(text).promote(); } else if (RelativeDateTimeFormat.TODAY_PATTERN.matcher(text).matches()) { return IntervalOfTime.today().toClosed(); } else { return create(text, "Today", true, true); } } else { return create(text.substring(0, doubleDots), text.substring(doubleDots + DEFAULT_SEPARATOR.length()), true, true); } } } }
IntervalOfTimeFormatter { public IntervalOfTime parseInterval(String text) { if (text == null || text.length() == 0) return null; if (intervalForm) { boolean lowClosed; boolean highClosed; if (text.startsWith("[")) { lowClosed = true; } else if (text.startsWith("]")) { lowClosed = false; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } if (text.endsWith("[")) { highClosed = false; } else if (text.endsWith("]")) { highClosed = true; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } int semicolon = text.indexOf(INTERVAL_FORM_SEPARATOR); if (semicolon == -1) throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); return create(text.substring(1, semicolon), text.substring(semicolon + INTERVAL_FORM_SEPARATOR.length(), text.length() - 1), lowClosed, highClosed); } else { int doubleDots = text.indexOf(DEFAULT_SEPARATOR); if (doubleDots == -1) { if (HL7DateTimeFormat.HL7_PATTERN.matcher(text).matches()) { return HL7DateTimeFormat.parse(text).promote(); } else if (RelativeDateTimeFormat.TODAY_PATTERN.matcher(text).matches()) { return IntervalOfTime.today().toClosed(); } else { return create(text, "Today", true, true); } } else { return create(text.substring(0, doubleDots), text.substring(doubleDots + DEFAULT_SEPARATOR.length()), true, true); } } } IntervalOfTimeFormatter();  IntervalOfTimeFormatter(boolean intervalForm); }
IntervalOfTimeFormatter { public IntervalOfTime parseInterval(String text) { if (text == null || text.length() == 0) return null; if (intervalForm) { boolean lowClosed; boolean highClosed; if (text.startsWith("[")) { lowClosed = true; } else if (text.startsWith("]")) { lowClosed = false; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } if (text.endsWith("[")) { highClosed = false; } else if (text.endsWith("]")) { highClosed = true; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } int semicolon = text.indexOf(INTERVAL_FORM_SEPARATOR); if (semicolon == -1) throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); return create(text.substring(1, semicolon), text.substring(semicolon + INTERVAL_FORM_SEPARATOR.length(), text.length() - 1), lowClosed, highClosed); } else { int doubleDots = text.indexOf(DEFAULT_SEPARATOR); if (doubleDots == -1) { if (HL7DateTimeFormat.HL7_PATTERN.matcher(text).matches()) { return HL7DateTimeFormat.parse(text).promote(); } else if (RelativeDateTimeFormat.TODAY_PATTERN.matcher(text).matches()) { return IntervalOfTime.today().toClosed(); } else { return create(text, "Today", true, true); } } else { return create(text.substring(0, doubleDots), text.substring(doubleDots + DEFAULT_SEPARATOR.length()), true, true); } } } IntervalOfTimeFormatter();  IntervalOfTimeFormatter(boolean intervalForm); IntervalOfTime parseInterval(String text); static IntervalOfTime create(String start, String stop, boolean lowClosed, boolean highClosed); String print(IntervalOfTime interval); void printTo(StringBuffer buffer, IntervalOfTime interval); }
IntervalOfTimeFormatter { public IntervalOfTime parseInterval(String text) { if (text == null || text.length() == 0) return null; if (intervalForm) { boolean lowClosed; boolean highClosed; if (text.startsWith("[")) { lowClosed = true; } else if (text.startsWith("]")) { lowClosed = false; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } if (text.endsWith("[")) { highClosed = false; } else if (text.endsWith("]")) { highClosed = true; } else { throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); } int semicolon = text.indexOf(INTERVAL_FORM_SEPARATOR); if (semicolon == -1) throw new IllegalArgumentException("Unable to parse interval: " + text + " is not in interval form"); return create(text.substring(1, semicolon), text.substring(semicolon + INTERVAL_FORM_SEPARATOR.length(), text.length() - 1), lowClosed, highClosed); } else { int doubleDots = text.indexOf(DEFAULT_SEPARATOR); if (doubleDots == -1) { if (HL7DateTimeFormat.HL7_PATTERN.matcher(text).matches()) { return HL7DateTimeFormat.parse(text).promote(); } else if (RelativeDateTimeFormat.TODAY_PATTERN.matcher(text).matches()) { return IntervalOfTime.today().toClosed(); } else { return create(text, "Today", true, true); } } else { return create(text.substring(0, doubleDots), text.substring(doubleDots + DEFAULT_SEPARATOR.length()), true, true); } } } IntervalOfTimeFormatter();  IntervalOfTimeFormatter(boolean intervalForm); IntervalOfTime parseInterval(String text); static IntervalOfTime create(String start, String stop, boolean lowClosed, boolean highClosed); String print(IntervalOfTime interval); void printTo(StringBuffer buffer, IntervalOfTime interval);  }