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

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

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

DateTimeFormatter.getZone介绍

[英]Gets the zone to use as an override.
[中]获取要用作替代的区域。

代码示例

代码示例来源:origin: apache/incubator-pinot

protected String transformMillisToSDF(long millisSinceEpoch) {
 // convert to date time (with timezone), then truncate/bucket to the desired output granularity
 return _dateTimeTruncate.truncate(new DateTime(millisSinceEpoch, _outputDateTimeFormatter.getZone()));
}

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

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

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

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public ZoneId zone() {
  return DateUtils.dateTimeZoneToZoneId(printer.getZone());
}

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda

public JacksonJodaDateFormat(DateTimeFormatter defaultFormatter)
{
  super();
  _formatter = defaultFormatter;
  DateTimeZone tz = defaultFormatter.getZone();
  _jdkTimezone = (tz == null) ? null : tz.toTimeZone();
  _explicitTimezone = false;
  _adjustToContextTZOverride = null;
  _writeZoneId = null;
}

代码示例来源:origin: apache/phoenix

@Override
  public TimeZone getTimeZone() {
    return formatter.getZone().toTimeZone();
  }
}

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

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

@Override
  public TimeZone getTimeZone() {
    return formatter.getZone().toTimeZone();
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

private static DateTimeFormatter withZone(DateTimeFormatter dateTimeFormatter, DateTimeZone zoneId) {
  if (zoneId != null) {
    return dateTimeFormatter.withZone(zoneId);
  } else if (dateTimeFormatter.getZone() == null) {
    return dateTimeFormatter.withZone(DateTimeZone.getDefault());
  }
  return dateTimeFormatter;
}

代码示例来源:origin: org.apache.phoenix/phoenix-core

@Override
  public TimeZone getTimeZone() {
    return formatter.getZone().toTimeZone();
  }
}

代码示例来源:origin: qubole/streamx

@Override
public String encodePartition(SinkRecord sinkRecord) {
 long timestamp = System.currentTimeMillis();
 DateTime bucket = new DateTime(getPartition(partitionDurationMs, timestamp, formatter.getZone()));
 return bucket.toString(formatter);
}

代码示例来源:origin: confluentinc/camus

@Override
public String encodePartition(JobContext context, IEtlKey key) {
 return Long.toString(DateUtils.getPartition(outfilePartitionMillis, key.getTime(), outputDirFormatter.getZone()));
}

代码示例来源:origin: com.linkedin.camus/camus-etl-kafka

@Override
public String encodePartition(JobContext context, IEtlKey key) {
 return Long.toString(DateUtils.getPartition(outfilePartitionMillis, key.getTime(), outputDirFormatter.getZone()));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

代码示例来源:origin: redfish64/TinyTravelTracker

/**
 * Extracts the values of the partial from an object of this converter's type.
 * This method checks if the parser has a zone, and uses it if present.
 * This is most useful for parsing local times with UTC.
 * 
 * @param fieldSource  a partial that provides access to the fields.
 *  This partial may be incomplete and only getFieldType(int) should be used
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is the non-null result of getChronology()
 * @param parser the parser to use, may be null
 * @return the array of field values that match the fieldSource, must be non-null valid
 * @throws ClassCastException if the object is invalid
 * @throws IllegalArgumentException if the value if invalid
 * @since 1.3
 */
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
  if (parser.getZone() != null) {
    chrono = chrono.withZone(parser.getZone());
  }
  long millis = parser.withChronology(chrono).parseMillis((String) object);
  return chrono.get(fieldSource, millis);
}

代码示例来源:origin: confluentinc/camus

@Override
public String encodePartition(JobContext context, IEtlKey key) {
 long outfilePartitionMs = EtlMultiOutputFormat.getEtlOutputFileTimePartitionMins(context) * 60000L;
 return "" + DateUtils.getPartition(outfilePartitionMs, key.getTime(), outputDateFormatter.getZone());
}

代码示例来源:origin: com.linkedin.camus/camus-etl-kafka

@Override
public String encodePartition(JobContext context, IEtlKey key) {
 long outfilePartitionMs = EtlMultiOutputFormat.getEtlOutputFileTimePartitionMins(context) * 60000L;
 return "" + DateUtils.getPartition(outfilePartitionMs, key.getTime(), outputDateFormatter.getZone());
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@SuppressWarnings("unchecked")
@Override
public ContextualConverter<? super I, ? extends O> newConverter(ConvertingTypes targetedTypes, ContextFactoryBuilder contextFactoryBuilder, Object... params) {
  DateTimeFormatter[] dateTimeFormatters = JodaTimeHelper.getDateTimeFormatters(params);
  DateTimeZone zoneId = JodaTimeHelper.getDateTimeZoneOrDefault(params);
  ContextualConverter<I, O>[] converters = new ContextualConverter[dateTimeFormatters.length];
  for(int i = 0; i < dateTimeFormatters.length; i++) {
    DateTimeFormatter dateTimeFormatter = dateTimeFormatters[i];
    if (dateTimeFormatter.getZone() == null) {
      dateTimeFormatter.withZone(zoneId);
    }
    converters[i] = newConverter(dateTimeFormatter);
  }
  if (converters.length == 1) {
    return converters[0];
  } else {
    return new MultiDateTimeFormatterConverter<I, O>(converters);
  }
}

相关文章