org.joda.time.format.DateTimeFormatter.selectChronology()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.joda.time.format.DateTimeFormatter.selectChronology()方法的一些代码示例,展示了DateTimeFormatter.selectChronology()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTimeFormatter.selectChronology()方法的具体详情如下:
包路径:org.joda.time.format.DateTimeFormatter
类名称:DateTimeFormatter
方法名:selectChronology

DateTimeFormatter.selectChronology介绍

[英]Determines the correct chronology to use.
[中]确定要使用的正确年表。

代码示例

代码示例来源:origin: JodaOrg/joda-time

/**
 * 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);
}

代码示例来源:origin: joda-time/joda-time

/**
 * 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);
}

代码示例来源:origin: joda-time/joda-time

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);
}

代码示例来源:origin: JodaOrg/joda-time

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);
}

代码示例来源:origin: joda-time/joda-time

InternalParser parser = requireParser();
Chronology chrono = selectChronology(null);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser.parseInto(bucket, text, 0);

代码示例来源:origin: JodaOrg/joda-time

InternalParser parser = requireParser();
Chronology chrono = selectChronology(null);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser.parseInto(bucket, text, 0);

代码示例来源:origin: JodaOrg/joda-time

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);

代码示例来源:origin: joda-time/joda-time

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);

代码示例来源:origin: joda-time/joda-time

InternalParser parser = requireParser();
Chronology chrono = selectChronology(null);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser.parseInto(bucket, text, 0);

代码示例来源:origin: JodaOrg/joda-time

InternalParser parser = requireParser();
Chronology chrono = selectChronology(null);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser.parseInto(bucket, text, 0);

代码示例来源:origin: joda-time/joda-time

int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis);
long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis);
chrono = selectChronology(chrono);

代码示例来源:origin: JodaOrg/joda-time

int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis);
long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis);
chrono = selectChronology(chrono);

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * 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));
}

代码示例来源:origin: camunda/camunda-bpm-platform

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);
}

代码示例来源:origin: camunda/camunda-bpm-platform

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);
}

代码示例来源:origin: camunda/camunda-bpm-platform

DateTimeParser parser = requireParser();
Chronology chrono = selectChronology(null);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser.parseInto(bucket, text, 0);

代码示例来源:origin: camunda/camunda-bpm-platform

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);

代码示例来源:origin: camunda/camunda-bpm-platform

DateTimeParser parser = requireParser();
Chronology chrono = selectChronology(null);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser.parseInto(bucket, text, 0);

代码示例来源:origin: camunda/camunda-bpm-platform

Chronology chrono = instant.getChronology();
long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis);
chrono = selectChronology(chrono);

代码示例来源:origin: org.joda/com.springsource.org.joda.time

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);
}

相关文章