org.joda.time.LocalDateTime.year()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(124)

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

LocalDateTime.year介绍

[英]Get the year property which provides access to advanced functionality.
[中]获取提供高级功能访问权限的year属性。

代码示例

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

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

@Override
  public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider provider)
    throws IOException
  {
    switch (_serializationShape(provider)) {
    case FORMAT_STRING:
      gen.writeString(_format.createFormatter(provider).print(value));
      break;
    case FORMAT_TIMESTAMP:
      {
        // copied from `LocalDateTimeDeserializer`...
        DateTimeZone tz = _format.isTimezoneExplicit() ? _format.getTimeZone()
            : DateTimeZone.forTimeZone(provider.getTimeZone());
        gen.writeNumber(value.toDateTime(tz).getMillis());
      }
      break;
    case FORMAT_ARRAY:
      // Timestamp here actually means an array of values
      gen.writeStartArray();
      gen.writeNumber(value.year().get());
      gen.writeNumber(value.monthOfYear().get());
      gen.writeNumber(value.dayOfMonth().get());
      gen.writeNumber(value.hourOfDay().get());
      gen.writeNumber(value.minuteOfHour().get());
      gen.writeNumber(value.secondOfMinute().get());
      gen.writeNumber(value.millisOfSecond().get());
      gen.writeEndArray();
    }
  }
}

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

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

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

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

代码示例来源:origin: dremio/dremio-oss

return tmpValue.year().roundFloorCopy();
} else {
 return tmpValue.year().roundCeilingCopy();
 LocalDateTime roundeddown = tmpValue.year().roundFloorCopy();
 int year = roundeddown.getYear();
 int roundedDownYear = year % 10;
 return roundeddown.minusYears(roundedDownYear);
} else {
 LocalDateTime roundedUp = tmpValue.year().roundCeilingCopy();
 int year = roundedUp.getYear();
 int roundedUpYear = 10 - year % 10;
 LocalDateTime roundeddown = tmpValue.year().roundFloorCopy();
 int year = roundeddown.getYear();
 int roundedDownYear = year % 100;
 return roundeddown.minusYears(roundedDownYear);
} else {
 LocalDateTime roundedUp = tmpValue.year().roundCeilingCopy();
 int year = roundedUp.getYear();
 int roundedUpYear = 100 - year % 100;
 LocalDateTime roundeddown = tmpValue.year().roundFloorCopy();
 int year = roundeddown.getYear();
 int roundedDownYear = year % 1000;
 return roundeddown.minusYears(roundedDownYear);
} else {
 LocalDateTime roundedUp = tmpValue.year().roundCeilingCopy();
 int year = roundedUp.getYear();

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

@Override
public void serialize(LocalDateTime dt, JsonGenerator jgen, SerializerProvider provider)
  throws IOException, JsonGenerationException
{
  if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
    // Timestamp here actually means an array of values
    jgen.writeStartArray();
    jgen.writeNumber(dt.year().get());
    jgen.writeNumber(dt.monthOfYear().get());
    jgen.writeNumber(dt.dayOfMonth().get());
    jgen.writeNumber(dt.hourOfDay().get());
    jgen.writeNumber(dt.minuteOfHour().get());
    jgen.writeNumber(dt.secondOfMinute().get());
    jgen.writeNumber(dt.millisOfSecond().get());
    jgen.writeEndArray();
  } else {
    jgen.writeString(printLocalDateTime(dt));
  }
}

相关文章