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

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

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

LocalTime.getLong介绍

[英]Gets the value of the specified field from this time as a long.

This queries this time for the value for the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.

If the field is a ChronoField then the query is implemented here. The #isSupported(TemporalField) will return valid values based on this time. All other ChronoField instances will throw a DateTimeException.

If the field is not a ChronoField, then the result of this method is obtained by invoking TemporalField.getFrom(TemporalAccessor)passing this as the argument. Whether the value can be obtained, and what the value represents, is determined by the field.
[中]获取指定字段的值,该值从此时间起为long。
这一次将查询指定字段的值。如果由于字段不受支持或其他原因而无法返回值,则会引发异常。
如果该字段是一个ChronoField,则在此处实现查询。#isSupported(临时字段)将基于此时间返回有效值。所有其他ChronoField实例将引发DateTimeException。
如果字段不是ChronoField,则通过调用TemporalField获得此方法的结果。getFrom(临时Accessor)将此作为参数传递。是否可以获得该值以及该值表示的内容由字段决定。

代码示例

代码示例来源:origin: org.springframework.data/spring-data-cassandra

@Override
  public Long convert(LocalTime source) {
    return source.getLong(ChronoField.MILLI_OF_DAY);
  }
}

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

@Override
public long getLong(TemporalField field) {
  if (field instanceof ChronoField) {
    return (field.isTimeBased() ? time.getLong(field) : date.getLong(field));
  }
  return field.getFrom(this);
}

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

@Override
public long getLong(TemporalField field) {
  if (field instanceof ChronoField) {
    return (field.isTimeBased() ? time.getLong(field) : date.getLong(field));
  }
  return field.getFrom(this);
}

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

/**
 * Gets the value of the specified field from this date-time as a {@code long}.
 * <p>
 * This queries this date-time for the value for the specified field.
 * If it is not possible to return the value, because the field is not supported
 * or for some other reason, an exception is thrown.
 * <p>
 * If the field is a {@link ChronoField} then the query is implemented here.
 * The {@link #isSupported(TemporalField) supported fields} will return valid
 * values based on this date-time.
 * All other {@code ChronoField} instances will throw a {@code DateTimeException}.
 * <p>
 * If the field is not a {@code ChronoField}, then the result of this method
 * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)}
 * passing {@code this} as the argument. Whether the value can be obtained,
 * and what the value represents, is determined by the field.
 *
 * @param field  the field to get, not null
 * @return the value for the field
 * @throws DateTimeException if a value for the field cannot be obtained
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public long getLong(TemporalField field) {
  if (field instanceof ChronoField) {
    return (field.isTimeBased() ? time.getLong(field) : date.getLong(field));
  }
  return field.getFrom(this);
}

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

return getOffset().getTotalSeconds();
return time.getLong(field);

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

/**
 * Gets the value of the specified field from this date-time as a {@code long}.
 * <p>
 * This queries this date-time for the value for the specified field.
 * If it is not possible to return the value, because the field is not supported
 * or for some other reason, an exception is thrown.
 * <p>
 * If the field is a {@link ChronoField} then the query is implemented here.
 * The {@link #isSupported(TemporalField) supported fields} will return valid
 * values based on this date-time.
 * All other {@code ChronoField} instances will throw a {@code DateTimeException}.
 * <p>
 * If the field is not a {@code ChronoField}, then the result of this method
 * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)}
 * passing {@code this} as the argument. Whether the value can be obtained,
 * and what the value represents, is determined by the field.
 *
 * @param field  the field to get, not null
 * @return the value for the field
 * @throws DateTimeException if a value for the field cannot be obtained
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public long getLong(TemporalField field) {
  if (field instanceof ChronoField) {
    return (field.isTimeBased() ? time.getLong(field) : date.getLong(field));
  }
  return field.getFrom(this);
}

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

return getOffset().getTotalSeconds();
return time.getLong(field);

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

@Override
public long getLong(TemporalField field) {
  Jdk8Methods.requireNonNull(field, "field");
  Long value = getFieldValue0(field);
  if (value == null) {
    if (date != null && date.isSupported(field)) {
      return date.getLong(field);
    }
    if (time != null && time.isSupported(field)) {
      return time.getLong(field);
    }
    throw new DateTimeException("Field not found: " + field);
  }
  return value;
}

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

@Override
public long getLong(TemporalField field) {
  Jdk8Methods.requireNonNull(field, "field");
  Long value = getFieldValue0(field);
  if (value == null) {
    if (date != null && date.isSupported(field)) {
      return date.getLong(field);
    }
    if (time != null && time.isSupported(field)) {
      return time.getLong(field);
    }
    throw new DateTimeException("Field not found: " + field);
  }
  return value;
}

相关文章