本文整理了Java中java.time.ZonedDateTime.get()
方法的一些代码示例,展示了ZonedDateTime.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.get()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:get
[英]Gets the value of the specified field from this date-time as an int.
This queries this date-time for the value for the specified field. The returned value will always be within the valid range of values for the 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 date-time, except NANO_OF_DAY, MICRO_OF_DAY, EPOCH_DAY, EPOCH_MONTH and INSTANT_SECONDS which are too large to fit in an int and throw a DateTimeException. 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.
[中]从该日期时间获取指定字段的int值。
这将查询此日期时间以获取指定字段的值。返回的值将始终在字段的有效值范围内。如果由于字段不受支持或其他原因而无法返回值,则会引发异常。
如果该字段是一个ChronoField,则在此处实现查询。#isSupported(TemporalField)将基于此日期时间返回有效值,但NANO_OF_DAY、MICRO_OF_DAY、EPOCH_DAY、EPOCH_MONTH和INSTANT_SECONDS除外,这些值太大,无法放入整数并引发DateTimeException。所有其他ChronoField实例将抛出DateTimeException。
如果该字段不是ChronoField,则通过调用TemporalField获得该方法的结果。getFrom(临时助理)将此作为参数传递。是否可以获得该值,以及该值代表什么,取决于字段。
代码示例来源:origin: runelite/runelite
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent event)
{
if (!event.getEventName().equals("addTimestamp"))
{
return;
}
int[] intStack = client.getIntStack();
int intStackSize = client.getIntStackSize();
String[] stringStack = client.getStringStack();
int stringStackSize = client.getStringStackSize();
int messageId = intStack[intStackSize - 1];
MessageNode messageNode = (MessageNode) client.getMessages().get(messageId);
final ZonedDateTime time = ZonedDateTime.ofInstant(
Instant.ofEpochSecond(messageNode.getTimestamp()), ZoneId.systemDefault());
final String dateFormat = time.get(ChronoField.HOUR_OF_DAY) + ":" +
String.format("%02d", time.get(ChronoField.MINUTE_OF_HOUR));
String timestamp = "[" + dateFormat + "] ";
Color timestampColour = getTimestampColour();
if (timestampColour != null)
{
timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour);
}
stringStack[stringStackSize - 1] = timestamp;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getYearOfEra() {
logDeprecatedMethod("getYearOfEra()", "get(ChronoField.YEAR_OF_ERA)");
return dt.get(ChronoField.YEAR_OF_ERA);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getEra() {
logDeprecatedMethod("getEra()", "get(ChronoField.ERA)");
return dt.get(ChronoField.ERA);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getMillisOfDay() {
logDeprecatedMethod("getMillisOfDay()", "get(ChronoField.MILLI_OF_DAY)");
return dt.get(ChronoField.MILLI_OF_DAY);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getYearOfCentury() {
logDeprecatedMethod("getYearOfCentury()", "get(ChronoField.YEAR_OF_ERA) % 100");
return dt.get(ChronoField.YEAR_OF_ERA) % 100;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getMinuteOfDay() {
logDeprecatedMethod("getMinuteOfDay()", "get(ChronoField.MINUTE_OF_DAY)");
return dt.get(ChronoField.MINUTE_OF_DAY);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getCenturyOfEra() {
logDeprecatedMethod("getCenturyOfEra()", "get(ChronoField.YEAR_OF_ERA) / 100");
return dt.get(ChronoField.YEAR_OF_ERA) / 100;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getMillisOfSecond() {
logDeprecatedMethod("getMillisOfSecond()", "get(ChronoField.MILLI_OF_SECOND)");
return dt.get(ChronoField.MILLI_OF_SECOND);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getSecondOfDay() {
logDeprecatedMethod("getSecondOfDay()", "get(ChronoField.SECOND_OF_DAY)");
return dt.get(ChronoField.SECOND_OF_DAY);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getWeekOfWeekyear() {
logDeprecatedMethod("getWeekOfWeekyear()", "get(WeekFields.ISO.weekOfWeekBasedYear())");
return dt.get(WeekFields.ISO.weekOfWeekBasedYear());
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getWeekyear() {
logDeprecatedMethod("getWeekyear()", "get(WeekFields.ISO.weekBasedYear())");
return dt.get(WeekFields.ISO.weekBasedYear());
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@UserFunction
@Description("apoc.date.field(12345,('ms|s|m|h|d|month|year'),('TZ')")
public Long field(final @Name("time") Long time, @Name(value = "unit", defaultValue = "d") String unit, @Name(value = "timezone",defaultValue = "UTC") String timezone) {
return (time == null)
? null
: (long) ZonedDateTime
.ofInstant( Instant.ofEpochMilli( time ), ZoneId.of( timezone ) )
.get( chronoField( unit ) );
}
代码示例来源:origin: stackoverflow.com
public static int getCurrentTimeInBeats() {
ZonedDateTime now = ZonedDateTime.now( ZoneId.of( "UTC+01:00" ) ); // "Biel Meantime" = UTC+01:00
int beats = (int) ( ( now.get( ChronoField.SECOND_OF_MINUTE) + ( now.get( ChronoField.MINUTE_OF_HOUR ) * 60 ) + ( now.get( ChronoField.HOUR_OF_DAY) * 3600 ) ) / 86.4 );
return beats;
}
代码示例来源:origin: stackoverflow.com
ZoneId zoneId = ZoneId.of ( "America/Montreal" );
ZonedDateTime now = ZonedDateTime.now ( zoneId );
int weekOfYear = now.get ( IsoFields.WEEK_OF_WEEK_BASED_YEAR );
int weekBasedYear = now.get ( IsoFields.WEEK_BASED_YEAR );
System.out.println ( "weekOfYear: " + weekOfYear + " of weekBasedYear: " + weekBasedYear );
代码示例来源:origin: stackoverflow.com
ZoneId zoneId = ZoneId.of( "America/Montreal" );
LocalDate twelves = LocalDate.of( 2012 , 12 , 12 );
ZonedDateTime twelvesMontreal = twelves.atStartOfDay( zoneId );
int week = twelvesMontreal.get ( IsoFields.WEEK_OF_WEEK_BASED_YEAR );
int weekYear = twelvesMontreal.get ( IsoFields.WEEK_BASED_YEAR );
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Deprecated
public int getMillisOfDay() {
logDeprecatedMethod("getMillisOfDay()", "get(ChronoField.MILLI_OF_DAY)");
return dt.get(ChronoField.MILLI_OF_DAY);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Deprecated
public int getMinuteOfDay() {
logDeprecatedMethod("getMinuteOfDay()", "get(ChronoField.MINUTE_OF_DAY)");
return dt.get(ChronoField.MINUTE_OF_DAY);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Deprecated
public int getYearOfEra() {
logDeprecatedMethod("getYearOfEra()", "get(ChronoField.YEAR_OF_ERA)");
return dt.get(ChronoField.YEAR_OF_ERA);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Deprecated
public int getCenturyOfEra() {
logDeprecatedMethod("getCenturyOfEra()", "get(ChronoField.YEAR_OF_ERA) / 100");
return dt.get(ChronoField.YEAR_OF_ERA) / 100;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Deprecated
public int getEra() {
logDeprecatedMethod("getEra()", "get(ChronoField.ERA)");
return dt.get(ChronoField.ERA);
}
内容来源于网络,如有侵权,请联系作者删除!