static InternalParser of(DateTimeParser underlying) { if (underlying instanceof InternalParserDateTimeParser) { return (InternalParser) underlying; } if (underlying == null) { return null; } return new DateTimeParserInternalParser(underlying); }
static DateTimeParser of(InternalParser underlying) { if (underlying instanceof DateTimeParserInternalParser) { return ((DateTimeParserInternalParser) underlying).getUnderlying(); } if (underlying instanceof DateTimeParser) { return (DateTimeParser) underlying; } if (underlying == null) { return null; } return new InternalParserDateTimeParser(underlying); }
/** * Creates a new formatter, however you will normally use the factory * or the builder. * * @param printer the internal printer, null if cannot print * @param parser the internal parser, null if cannot parse */ public DateTimeFormatter( DateTimePrinter printer, DateTimeParser parser) { this(DateTimePrinterInternalPrinter.of(printer), DateTimeParserInternalParser.of(parser)); }
/** * Creates a new formatter, however you will normally use the factory * or the builder. * * @param printer the internal printer, null if cannot print * @param parser the internal parser, null if cannot parse */ public DateTimeFormatter( DateTimePrinter printer, DateTimeParser parser) { this(DateTimePrinterInternalPrinter.of(printer), DateTimeParserInternalParser.of(parser)); }
static InternalParser of(DateTimeParser underlying) { if (underlying instanceof InternalParserDateTimeParser) { return (InternalParser) underlying; } if (underlying == null) { return null; } return new DateTimeParserInternalParser(underlying); }
static DateTimeParser of(InternalParser underlying) { if (underlying instanceof DateTimeParserInternalParser) { return ((DateTimeParserInternalParser) underlying).getUnderlying(); } if (underlying instanceof DateTimeParser) { return (DateTimeParser) underlying; } if (underlying == null) { return null; } return new InternalParserDateTimeParser(underlying); }
/** * Parses a datetime from the given text, returning the number of * milliseconds since the epoch, 1970-01-01T00:00:00Z. * <p> * This parses the text using the parser into this bucket. * The bucket is reset before parsing begins, allowing the bucket to be re-used. * The bucket must not be shared between threads. * * @param parser the parser to use, see {@link DateTimeFormatter#getParser()}, not null * @param text text to parse, not null * @return parsed value expressed in milliseconds since the epoch * @throws UnsupportedOperationException if parsing is not supported * @throws IllegalArgumentException if the text to parse is invalid * @since 2.4 */ public long parseMillis(DateTimeParser parser, CharSequence text) { reset(); return doParseMillis(DateTimeParserInternalParser.of(parser), text); }
static InternalParser of(DateTimeParser underlying) { if (underlying instanceof InternalParserDateTimeParser) { return (InternalParser) underlying; } if (underlying == null) { return null; } return new DateTimeParserInternalParser(underlying); }
static DateTimeParser of(InternalParser underlying) { if (underlying instanceof DateTimeParserInternalParser) { return ((DateTimeParserInternalParser) underlying).getUnderlying(); } if (underlying instanceof DateTimeParser) { return (DateTimeParser) underlying; } if (underlying == null) { return null; } return new InternalParserDateTimeParser(underlying); }
/** * Appends just a parser. With no matching printer, a printer cannot be * built from this builder. * <p> * The parser interface is part of the low-level part of the formatting API. * Normally, instances are extracted from another formatter. * Note however that any formatter specific information, such as the locale, * time-zone, chronology, offset parsing or pivot/default year, will not be * extracted by this method. * * @param parser the parser to add, not null * @return this DateTimeFormatterBuilder, for chaining * @throws IllegalArgumentException if parser is null or of an invalid type */ public DateTimeFormatterBuilder append(DateTimeParser parser) { checkParser(parser); return append0(null, DateTimeParserInternalParser.of(parser)); }
static InternalParser of(DateTimeParser underlying) { if (underlying instanceof InternalParserDateTimeParser) { return (InternalParser) underlying; } if (underlying == null) { return null; } return new DateTimeParserInternalParser(underlying); }
static DateTimeParser of(InternalParser underlying) { if (underlying instanceof DateTimeParserInternalParser) { return ((DateTimeParserInternalParser) underlying).getUnderlying(); } if (underlying instanceof DateTimeParser) { return (DateTimeParser) underlying; } if (underlying == null) { return null; } return new InternalParserDateTimeParser(underlying); }
/** * Appends just a parser. With no matching printer, a printer cannot be * built from this builder. * <p> * The parser interface is part of the low-level part of the formatting API. * Normally, instances are extracted from another formatter. * Note however that any formatter specific information, such as the locale, * time-zone, chronology, offset parsing or pivot/default year, will not be * extracted by this method. * * @param parser the parser to add, not null * @return this DateTimeFormatterBuilder, for chaining * @throws IllegalArgumentException if parser is null or of an invalid type */ public DateTimeFormatterBuilder append(DateTimeParser parser) { checkParser(parser); return append0(null, DateTimeParserInternalParser.of(parser)); }
/** * Parses a datetime from the given text, returning the number of * milliseconds since the epoch, 1970-01-01T00:00:00Z. * <p> * This parses the text using the parser into this bucket. * The bucket is reset before parsing begins, allowing the bucket to be re-used. * The bucket must not be shared between threads. * * @param parser the parser to use, see {@link DateTimeFormatter#getParser()}, not null * @param text text to parse, not null * @return parsed value expressed in milliseconds since the epoch * @throws UnsupportedOperationException if parsing is not supported * @throws IllegalArgumentException if the text to parse is invalid * @since 2.4 */ public long parseMillis(DateTimeParser parser, CharSequence text) { reset(); return doParseMillis(DateTimeParserInternalParser.of(parser), text); }
throw new IllegalArgumentException("No parser supplied"); return append0(DateTimePrinterInternalPrinter.of(printer), DateTimeParserInternalParser.of(parsers[0])); int i; for (i = 0; i < length - 1; i++) { if ((copyOfParsers[i] = DateTimeParserInternalParser.of(parsers[i])) == null) { throw new IllegalArgumentException("Incomplete parser array"); copyOfParsers[i] = DateTimeParserInternalParser.of(parsers[i]);
/** * Appends just a parser element which is optional. With no matching * printer, a printer cannot be built from this DateTimeFormatterBuilder. * <p> * The parser interface is part of the low-level part of the formatting API. * Normally, instances are extracted from another formatter. * Note however that any formatter specific information, such as the locale, * time-zone, chronology, offset parsing or pivot/default year, will not be * extracted by this method. * * @return this DateTimeFormatterBuilder, for chaining * @throws IllegalArgumentException if parser is null or of an invalid type */ public DateTimeFormatterBuilder appendOptional(DateTimeParser parser) { checkParser(parser); InternalParser[] parsers = new InternalParser[] {DateTimeParserInternalParser.of(parser), null}; return append0(null, new MatchingParser(parsers)); }
throw new IllegalArgumentException("No parser supplied"); return append0(DateTimePrinterInternalPrinter.of(printer), DateTimeParserInternalParser.of(parsers[0])); int i; for (i = 0; i < length - 1; i++) { if ((copyOfParsers[i] = DateTimeParserInternalParser.of(parsers[i])) == null) { throw new IllegalArgumentException("Incomplete parser array"); copyOfParsers[i] = DateTimeParserInternalParser.of(parsers[i]);
/** * Appends just a parser element which is optional. With no matching * printer, a printer cannot be built from this DateTimeFormatterBuilder. * <p> * The parser interface is part of the low-level part of the formatting API. * Normally, instances are extracted from another formatter. * Note however that any formatter specific information, such as the locale, * time-zone, chronology, offset parsing or pivot/default year, will not be * extracted by this method. * * @return this DateTimeFormatterBuilder, for chaining * @throws IllegalArgumentException if parser is null or of an invalid type */ public DateTimeFormatterBuilder appendOptional(DateTimeParser parser) { checkParser(parser); InternalParser[] parsers = new InternalParser[] {DateTimeParserInternalParser.of(parser), null}; return append0(null, new MatchingParser(parsers)); }
/** * Appends a printer/parser pair. * <p> * The printer and parser interfaces are the low-level part of the formatting API. * Normally, instances are extracted from another formatter. * Note however that any formatter specific information, such as the locale, * time-zone, chronology, offset parsing or pivot/default year, will not be * extracted by this method. * * @param printer the printer to add, not null * @param parser the parser to add, not null * @return this DateTimeFormatterBuilder, for chaining * @throws IllegalArgumentException if printer or parser is null or of an invalid type */ public DateTimeFormatterBuilder append(DateTimePrinter printer, DateTimeParser parser) { checkPrinter(printer); checkParser(parser); return append0(DateTimePrinterInternalPrinter.of(printer), DateTimeParserInternalParser.of(parser)); }
/** * Appends a printer/parser pair. * <p> * The printer and parser interfaces are the low-level part of the formatting API. * Normally, instances are extracted from another formatter. * Note however that any formatter specific information, such as the locale, * time-zone, chronology, offset parsing or pivot/default year, will not be * extracted by this method. * * @param printer the printer to add, not null * @param parser the parser to add, not null * @return this DateTimeFormatterBuilder, for chaining * @throws IllegalArgumentException if printer or parser is null or of an invalid type */ public DateTimeFormatterBuilder append(DateTimePrinter printer, DateTimeParser parser) { checkPrinter(printer); checkParser(parser); return append0(DateTimePrinterInternalPrinter.of(printer), DateTimeParserInternalParser.of(parser)); }