/** * Parses a datetime from the given text, returning the number of * milliseconds since the epoch, 1970-01-01T00:00:00Z. * <p> * The parse will use the ISO chronology, and the default time zone. * If the text contains a time zone string then that will be taken into account. * * @param text the 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 */ public long parseMillis(String text) { InternalParser parser = requireParser(); Chronology chrono = selectChronology(iChrono); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); return bucket.doParseMillis(parser, text); }
/** * Parses a datetime from the given text, returning the number of * milliseconds since the epoch, 1970-01-01T00:00:00Z. * <p> * The parse will use the ISO chronology, and the default time zone. * If the text contains a time zone string then that will be taken into account. * * @param text the 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 */ public long parseMillis(String text) { InternalParser parser = requireParser(); Chronology chrono = selectChronology(iChrono); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); return bucket.doParseMillis(parser, text); }
private void printTo(Appendable appendable, long instant, Chronology chrono) throws IOException { InternalPrinter printer = requirePrinter(); chrono = selectChronology(chrono); // Shift instant into local time (UTC) to avoid excessive offset // calculations when printing multiple fields in a composite printer. DateTimeZone zone = chrono.getZone(); int offset = zone.getOffset(instant); long adjustedInstant = instant + offset; if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) { // Time zone offset overflow, so revert to UTC. zone = DateTimeZone.UTC; offset = 0; adjustedInstant = instant; } printer.printTo(appendable, adjustedInstant, chrono.withUTC(), offset, zone, iLocale); }
private void printTo(Appendable appendable, long instant, Chronology chrono) throws IOException { InternalPrinter printer = requirePrinter(); chrono = selectChronology(chrono); // Shift instant into local time (UTC) to avoid excessive offset // calculations when printing multiple fields in a composite printer. DateTimeZone zone = chrono.getZone(); int offset = zone.getOffset(instant); long adjustedInstant = instant + offset; if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) { // Time zone offset overflow, so revert to UTC. zone = DateTimeZone.UTC; offset = 0; adjustedInstant = instant; } printer.printTo(appendable, adjustedInstant, chrono.withUTC(), offset, zone, iLocale); }
InternalParser parser = requireParser(); Chronology chrono = selectChronology(null); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
InternalParser parser = requireParser(); Chronology chrono = selectChronology(null); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
InternalParser parser = requireParser(); Chronology chrono = selectChronology(null).withUTC(); // always use UTC, avoiding DST gaps DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
InternalParser parser = requireParser(); Chronology chrono = selectChronology(null).withUTC(); // always use UTC, avoiding DST gaps DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
InternalParser parser = requireParser(); Chronology chrono = selectChronology(null); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
InternalParser parser = requireParser(); Chronology chrono = selectChronology(null); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis); long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis); chrono = selectChronology(chrono);
int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis); long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis); chrono = selectChronology(chrono);
/** * Parses a datetime from the given text, returning the number of * milliseconds since the epoch, 1970-01-01T00:00:00Z. * <p> * The parse will use the ISO chronology, and the default time zone. * If the text contains a time zone string then that will be taken into account. * * @param text text to parse * @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 */ public long parseMillis(String text) { DateTimeParser parser = requireParser(); Chronology chrono = selectChronology(iChrono); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0); if (newPos >= 0) { if (newPos >= text.length()) { return bucket.computeMillis(true, text); } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
private void printTo(StringBuffer buf, long instant, Chronology chrono) { DateTimePrinter printer = requirePrinter(); chrono = selectChronology(chrono); // Shift instant into local time (UTC) to avoid excessive offset // calculations when printing multiple fields in a composite printer. DateTimeZone zone = chrono.getZone(); int offset = zone.getOffset(instant); long adjustedInstant = instant + offset; if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) { // Time zone offset overflow, so revert to UTC. zone = DateTimeZone.UTC; offset = 0; adjustedInstant = instant; } printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale); }
private void printTo(Writer buf, long instant, Chronology chrono) throws IOException { DateTimePrinter printer = requirePrinter(); chrono = selectChronology(chrono); // Shift instant into local time (UTC) to avoid excessive offset // calculations when printing multiple fields in a composite printer. DateTimeZone zone = chrono.getZone(); int offset = zone.getOffset(instant); long adjustedInstant = instant + offset; if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) { // Time zone offset overflow, so revert to UTC. zone = DateTimeZone.UTC; offset = 0; adjustedInstant = instant; } printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale); }
DateTimeParser parser = requireParser(); Chronology chrono = selectChronology(null); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
DateTimeParser parser = requireParser(); Chronology chrono = selectChronology(null).withUTC(); // always use UTC, avoiding DST gaps DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
DateTimeParser parser = requireParser(); Chronology chrono = selectChronology(null); DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear); int newPos = parser.parseInto(bucket, text, 0);
Chronology chrono = instant.getChronology(); long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis); chrono = selectChronology(chrono);
private void printTo(StringBuffer buf, long instant, Chronology chrono) { DateTimePrinter printer = requirePrinter(); chrono = selectChronology(chrono); // Shift instant into local time (UTC) to avoid excessive offset // calculations when printing multiple fields in a composite printer. DateTimeZone zone = chrono.getZone(); int offset = zone.getOffset(instant); long adjustedInstant = instant + offset; if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) { // Time zone offset overflow, so revert to UTC. zone = DateTimeZone.UTC; offset = 0; adjustedInstant = instant; } printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale); }