org.threeten.bp.LocalDateTime.getYear()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(173)

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

LocalDateTime.getYear介绍

[英]Gets the year field.

This method returns the primitive int value for the year.

The year returned by this method is proleptic as per get(YEAR). To obtain the year-of-era, use get(YEAR_OF_ERA.
[中]获取年份字段。
此方法返回该年的原始int值。
此方法返回的年份是根据get(年份)的预测值。要获取纪年,请使用get(纪年)。

代码示例

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Gets the year field.
 * <p>
 * This method returns the primitive {@code int} value for the year.
 * <p>
 * The year returned by this method is proleptic as per {@code get(YEAR)}.
 * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
 *
 * @return the year, from MIN_YEAR to MAX_YEAR
 */
public int getYear() {
  return dateTime.getYear();
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Gets the year field.
 * <p>
 * This method returns the primitive {@code int} value for the year.
 * <p>
 * The year returned by this method is proleptic as per {@code get(YEAR)}.
 * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
 *
 * @return the year, from MIN_YEAR to MAX_YEAR
 */
public int getYear() {
  return dateTime.getYear();
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Gets the year field.
 * <p>
 * This method returns the primitive {@code int} value for the year.
 * <p>
 * The year returned by this method is proleptic as per {@code get(YEAR)}.
 * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
 *
 * @return the year, from MIN_YEAR to MAX_YEAR
 */
public int getYear() {
  return dateTime.getYear();
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Gets the year field.
 * <p>
 * This method returns the primitive {@code int} value for the year.
 * <p>
 * The year returned by this method is proleptic as per {@code get(YEAR)}.
 * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
 *
 * @return the year, from MIN_YEAR to MAX_YEAR
 */
public int getYear() {
  return dateTime.getYear();
}

代码示例来源:origin: ThreeTen/threetenbp

int endYear = windowEnd.getYear();
for (TZRule lastRule : lastRuleList) {
  addRule(lastRule.year, endYear + 1, lastRule.month, lastRule.dayOfMonthIndicator,

代码示例来源:origin: org.threeten/threetenbp

int endYear = windowEnd.getYear();
for (TZRule lastRule : lastRuleList) {
  addRule(lastRule.year, endYear + 1, lastRule.month, lastRule.dayOfMonthIndicator,

代码示例来源:origin: org.threeten/threetenbp

/**
 * Adds a single transition rule to the current window.
 * <p>
 * This adds a rule such that the offset, expressed as a daylight savings amount,
 * changes at the specified date-time.
 *
 * @param transitionDateTime  the date-time that the transition occurs as defined by timeDefintion, not null
 * @param timeDefinition  the definition of how to convert local to actual time, not null
 * @param savingAmountSecs  the amount of saving from the standard offset after the transition in seconds
 * @return this, for chaining
 * @throws IllegalStateException if no window has yet been added
 * @throws IllegalStateException if the window already has fixed savings
 * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
 */
public ZoneRulesBuilder addRuleToWindow(
    LocalDateTime transitionDateTime,
    TimeDefinition timeDefinition,
    int savingAmountSecs) {
  Jdk8Methods.requireNonNull(transitionDateTime, "transitionDateTime");
  return addRuleToWindow(
      transitionDateTime.getYear(), transitionDateTime.getYear(),
      transitionDateTime.getMonth(), transitionDateTime.getDayOfMonth(),
      null, transitionDateTime.toLocalTime(), false, timeDefinition, savingAmountSecs);
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Adds a single transition rule to the current window.
 * <p>
 * This adds a rule such that the offset, expressed as a daylight savings amount,
 * changes at the specified date-time.
 *
 * @param transitionDateTime  the date-time that the transition occurs as defined by timeDefintion, not null
 * @param timeDefinition  the definition of how to convert local to actual time, not null
 * @param savingAmountSecs  the amount of saving from the standard offset after the transition in seconds
 * @return this, for chaining
 * @throws IllegalStateException if no window has yet been added
 * @throws IllegalStateException if the window already has fixed savings
 * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
 */
public ZoneRulesBuilder addRuleToWindow(
    LocalDateTime transitionDateTime,
    TimeDefinition timeDefinition,
    int savingAmountSecs) {
  Jdk8Methods.requireNonNull(transitionDateTime, "transitionDateTime");
  return addRuleToWindow(
      transitionDateTime.getYear(), transitionDateTime.getYear(),
      transitionDateTime.getMonth(), transitionDateTime.getDayOfMonth(),
      null, transitionDateTime.toLocalTime(), false, timeDefinition, savingAmountSecs);
}

代码示例来源:origin: ThreeTen/threetenbp

if (ldt.getYear() == -10000) {
  buf.replace(pos, pos + 2, Long.toString(hi - 1));
} else if (lo == 0) {

代码示例来源:origin: org.threeten/threetenbp

if (ldt.getYear() == -10000) {
  buf.replace(pos, pos + 2, Long.toString(hi - 1));
} else if (lo == 0) {

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

@Override
public void serialize(LocalDateTime value, JsonGenerator g, SerializerProvider provider)
  throws IOException
{
  if (useTimestamp(provider)) {
    g.writeStartArray();
    g.writeNumber(value.getYear());
    g.writeNumber(value.getMonthValue());
    g.writeNumber(value.getDayOfMonth());
    g.writeNumber(value.getHour());
    g.writeNumber(value.getMinute());
    if (value.getSecond() > 0 || value.getNano() > 0) {
      g.writeNumber(value.getSecond());
      if(value.getNano() > 0) {
        if (provider.isEnabled(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS))
          g.writeNumber(value.getNano());
        else
          g.writeNumber(value.get(ChronoField.MILLI_OF_SECOND));
      }
    }
    g.writeEndArray();
  } else {
    DateTimeFormatter dtf = _formatter;
    if (dtf == null) {
      dtf = _defaultFormatter();
    }
    g.writeString(value.format(dtf));
  }
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Converts a {@code LocalDateTime} to a {@code java.sql.Timestamp}.
 *
 * @param dateTime  the local date-time, not null
 * @return the SQL timestamp, not null
 */
@SuppressWarnings("deprecation")
public static Timestamp toSqlTimestamp(LocalDateTime dateTime) {
  return new Timestamp(
      dateTime.getYear() - 1900,
      dateTime.getMonthValue() - 1,
      dateTime.getDayOfMonth(),
      dateTime.getHour(),
      dateTime.getMinute(),
      dateTime.getSecond(),
      dateTime.getNano());
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Converts a {@code LocalDateTime} to a {@code java.sql.Timestamp}.
 *
 * @param dateTime  the local date-time, not null
 * @return the SQL timestamp, not null
 */
@SuppressWarnings("deprecation")
public static Timestamp toSqlTimestamp(LocalDateTime dateTime) {
  return new Timestamp(
      dateTime.getYear() - 1900,
      dateTime.getMonthValue() - 1,
      dateTime.getDayOfMonth(),
      dateTime.getHour(),
      dateTime.getMinute(),
      dateTime.getSecond(),
      dateTime.getNano());
}

代码示例来源:origin: ThreeTen/threetenbp

ZoneOffsetTransition[] transArray = findTransitionArray(dt.getYear());
Object info = null;
for (ZoneOffsetTransition trans : transArray) {

代码示例来源:origin: org.threeten/threetenbp

ZoneOffsetTransition[] transArray = findTransitionArray(dt.getYear());
Object info = null;
for (ZoneOffsetTransition trans : transArray) {

代码示例来源:origin: org.threeten/threetenbp

window.tidy(loopWindowStart.getYear());

代码示例来源:origin: ThreeTen/threetenbp

window.tidy(loopWindowStart.getYear());

代码示例来源:origin: ngs-doo/dsl-json

public static void serialize(final LocalDateTime value, final JsonWriter sw) {
  final int year = value.getYear();
  if (year < 0) {
    throw new SerializationException("Negative dates are not supported.");

相关文章