本文整理了Java中org.threeten.bp.LocalTime
类的一些代码示例,展示了LocalTime
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalTime
类的具体详情如下:
包路径:org.threeten.bp.LocalTime
类名称:LocalTime
[英]A time without time-zone in the ISO-8601 calendar system, such as 10:15:30.
LocalTime is an immutable date-time object that represents a time, often viewed as hour-minute-second. Time is represented to nanosecond precision. For example, the value "13:45.30.123456789" can be stored in a LocalTime.
It does not store or represent a date or time-zone. Instead, it is a description of the local time as seen on a wall clock. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. This API assumes that all calendar systems use the same representation, this class, for time-of-day.
This class is immutable and thread-safe.
[中]ISO-8601日历系统中没有时区的时间,如10:15:30。
LocalTime是一个不可变的日期-时间对象,它表示一个时间,通常被视为小时-分钟-秒。时间表示为纳秒精度。例如,值“13:45.30.123456789”可以存储在LocalTime中。
它不存储或表示日期或时区。相反,它是一个描述当地时间的挂钟。如果没有诸如偏移量或时区之类的附加信息,它不能表示时间线上的某个瞬间。
ISO-8601日历系统是当今世界大部分地区使用的现代民用日历系统。此API假定所有日历系统对一天中的时间使用相同的表示形式(此类)。
####实施者规范
这个类是不可变的,并且是线程安全的。
代码示例来源:origin: com.torodb.torod.backends/greenplum
@Override
public Void visit(ScalarTime value, StringBuilder arg) {
arg.append('\'')
//this prints the value on ISO-8601, which is the recommended format on PostgreSQL
.append(value.getValue().toString())
.append('\'');
return null;
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Is the transition local time midnight at the end of day.
* <p>
* The transition may be represented as occurring at 24:00.
*
* @return whether a local time of midnight is at the start or end of the day
*/
public boolean isMidnightEndOfDay() {
return adjustDays == 1 && time.equals(LocalTime.MIDNIGHT);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains an instance of {@code LocalTime} from a text string such as {@code 10:15}.
* <p>
* The string must represent a valid time and is parsed using
* {@link org.threeten.bp.format.DateTimeFormatter#ISO_LOCAL_TIME}.
*
* @param text the text to parse such as "10:15:30", not null
* @return the parsed local time, not null
* @throws DateTimeParseException if the text cannot be parsed
*/
public static LocalTime parse(CharSequence text) {
return parse(text, DateTimeFormatter.ISO_LOCAL_TIME);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Converts a {@code LocalTime} to a {@code java.sql.Time}.
*
* @param time the local time, not null
* @return the SQL time, not null
*/
@SuppressWarnings("deprecation")
public static java.sql.Time toSqlTime(LocalTime time) {
return new java.sql.Time(time.getHour(), time.getMinute(), time.getSecond());
}
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public void serialize(LocalTime value, JsonGenerator g, SerializerProvider provider) throws IOException
{
if (useTimestamp(provider)) {
g.writeStartArray();
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: ThreeTen/threetenbp
/**
* A hash code for this time.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
return time.hashCode() ^ offset.hashCode();
}
代码示例来源: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) {
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
final int timeSecs = time.toSecondOfDay() + adjustDays * SECS_PER_DAY;
final int stdOffset = standardOffset.getTotalSeconds();
final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
final int afterDiff = offsetAfter.getTotalSeconds() - stdOffset;
final int timeByte = (timeSecs % 3600 == 0 && timeSecs <= SECS_PER_DAY ?
(timeSecs == SECS_PER_DAY ? 24 : time.getHour()) : 31);
final int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255);
final int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3);
代码示例来源:origin: ThreeTen/threetenbp
/**
* Gets the hour-of-day field.
*
* @return the hour-of-day, from 0 to 23
*/
public int getHour() {
return time.getHour();
}
代码示例来源:origin: org.threeten/threetenbp
public int get(TemporalField field) {
if (field instanceof ChronoField) {
return (field.isTimeBased() ? time.get(field) : date.get(field));
代码示例来源:origin: ThreeTen/threetenbp
/**
* Gets the minute-of-hour field.
*
* @return the minute-of-hour, from 0 to 59
*/
public int getMinute() {
return time.getMinute();
}
代码示例来源:origin: com.torodb.kvdocument/mongowp-converter
@Override
public BsonValue<?> visit(KVTime value, Void arg) {
List<Entry<?>> entryList = new ArrayList<>(2);
entryList.add(new SimpleEntry<>("type", newString("KVTime")));
entryList.add(new SimpleEntry<>("value", newString(value.getValue().format(DateTimeFormatter.ISO_TIME))));
return newDocument(entryList);
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code LocalTime} to a {@code java.sql.Time}.
*
* @param time the local time, not null
* @return the SQL time, not null
*/
@SuppressWarnings("deprecation")
public static java.sql.Time toSqlTime(LocalTime time) {
return new java.sql.Time(time.getHour(), time.getMinute(), time.getSecond());
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* A hash code for this date-time.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
return date.hashCode() ^ time.hashCode();
}
代码示例来源: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
@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: org.threeten/threetenbp
final int timeSecs = time.toSecondOfDay() + adjustDays * SECS_PER_DAY;
final int stdOffset = standardOffset.getTotalSeconds();
final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
final int afterDiff = offsetAfter.getTotalSeconds() - stdOffset;
final int timeByte = (timeSecs % 3600 == 0 && timeSecs <= SECS_PER_DAY ?
(timeSecs == SECS_PER_DAY ? 24 : time.getHour()) : 31);
final int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255);
final int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3);
代码示例来源:origin: org.threeten/threetenbp
/**
* Gets the hour-of-day field.
*
* @return the hour-of-day, from 0 to 23
*/
public int getHour() {
return time.getHour();
}
代码示例来源:origin: ThreeTen/threetenbp
@Override
public int get(TemporalField field) {
if (field instanceof ChronoField) {
return (field.isTimeBased() ? time.get(field) : date.get(field));
}
return range(field).checkValidIntValue(getLong(field), field);
}
内容来源于网络,如有侵权,请联系作者删除!