- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.ZoneId.getId()
方法的一些代码示例,展示了ZoneId.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneId.getId()
方法的具体详情如下:
包路径:java.time.ZoneId
类名称:ZoneId
方法名:getId
[英]Gets the unique time-zone ID.
This ID uniquely defines this object. The format of an offset based ID is defined by ZoneOffset#getId().
[中]获取唯一的时区ID。
这个ID唯一地定义了这个对象。基于偏移量的ID的格式由ZoneOffset#getId()定义。
代码示例来源:origin: com.thoughtworks.xstream/xstream
@Override
public String toString(final Object obj) {
if (obj == null) {
return null;
}
final ZoneId zoneId = (ZoneId)obj;
return zoneId.getId();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public String getAsText() {
ZoneId value = (ZoneId) getValue();
return (value != null ? value.getId() : "");
}
代码示例来源:origin: org.springframework/spring-beans
@Override
public String getAsText() {
ZoneId value = (ZoneId) getValue();
return (value != null ? value.getId() : "");
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
protected DateTime evaluate(FunctionArgs args, EvaluationContext context, DateTimeZone timezone) {
final Object datish = value.required(args, context);
if (datish instanceof DateTime) {
return (DateTime) datish;
}
if (datish instanceof Date) {
return new DateTime(datish);
}
if (datish instanceof ZonedDateTime) {
final ZonedDateTime zonedDateTime = (ZonedDateTime) datish;
final DateTimeZone timeZone = DateTimeZone.forID(zonedDateTime.getZone().getId());
return new DateTime(zonedDateTime.toInstant().toEpochMilli(), timeZone);
}
return null;
}
代码示例来源:origin: neo4j/neo4j
private int compareNamedZonesWithMapping( ZoneId thisZone, ZoneId thatZone )
{
String thisZoneNormalized = TimeZones.map( TimeZones.map( thisZone.getId() ) );
String thatZoneNormalized = TimeZones.map( TimeZones.map( thatZone.getId() ) );
return thisZoneNormalized.compareTo( thatZoneNormalized );
}
代码示例来源:origin: neo4j/neo4j
@Override
public void writeDateTime( ZonedDateTime zonedDateTime )
{
buf.putLong( zonedDateTime.toEpochSecond() );
buf.putInt( zonedDateTime.getNano() );
final ZoneId zone = zonedDateTime.getZone();
if ( zone instanceof ZoneOffset )
{
final int offsetSeconds = ((ZoneOffset) zone).getTotalSeconds();
// lowest bit set to 0: it's a zone offset in seconds
buf.putInt( offsetSeconds << 1 );
}
else
{
// lowest bit set to 1: it's a zone id
final int zoneId = (TimeZones.map( zone.getId() ) << 1) | 1;
buf.putInt( zoneId );
}
}
}
代码示例来源:origin: neo4j/neo4j
private DateTimeValue( ZonedDateTime value )
{
ZoneId zone = value.getZone();
if ( zone instanceof ZoneOffset )
{
this.value = value;
}
else
{
// Do a 2-way lookup of the zone to make sure we only use the new name of renamed zones
ZoneId mappedZone = ZoneId.of( TimeZones.map( TimeZones.map( zone.getId() ) ) );
this.value = value.withZoneSameInstant( mappedZone );
}
this.epochSeconds = this.value.toEpochSecond();
}
代码示例来源:origin: prestodb/presto
return packDateTimeWithZone(parseResult.getLong(INSTANT_SECONDS) * 1000 + parseResult.getLong(MILLI_OF_SECOND), getTimeZoneKey(ZoneId.from(parseResult).getId()));
return packDateTimeWithZone(parseResult.get(MILLI_OF_DAY), getTimeZoneKey(ZoneId.from(parseResult).getId()));
代码示例来源:origin: OpenHFT/Chronicle-Queue
private boolean checkEnterpriseFeaturesRequested() {
boolean result = false;
if (readBufferMode != BufferMode.None)
result = onlyAvailableInEnterprise("Buffering");
if (writeBufferMode != BufferMode.None)
result = onlyAvailableInEnterprise("Buffering");
if (rollTimeZone != null && !rollTimeZone.getId().equals("UTC") && !rollTimeZone.getId().equals("Z"))
result = onlyAvailableInEnterprise("Non-UTC roll time zone");
if (wireType == WireType.DELTA_BINARY)
result = onlyAvailableInEnterprise("Wire type " + wireType.name());
if (encodingSupplier != null)
result = onlyAvailableInEnterprise("Encoding");
if (key != null)
result = onlyAvailableInEnterprise("Encryption");
if (hasPretouchIntervalMillis())
result = onlyAvailableInEnterprise("Out of process pretouching");
return result;
}
代码示例来源:origin: neo4j/neo4j
@Override
public boolean equals( Value other )
{
if ( other instanceof DateTimeValue )
{
ZonedDateTime that = ((DateTimeValue) other).value;
boolean res = value.toLocalDateTime().equals( that.toLocalDateTime() );
if ( res )
{
ZoneId thisZone = value.getZone();
ZoneId thatZone = that.getZone();
boolean thisIsOffset = thisZone instanceof ZoneOffset;
boolean thatIsOffset = thatZone instanceof ZoneOffset;
if ( thisIsOffset && thatIsOffset )
{
res = thisZone.equals( thatZone );
}
else if ( !thisIsOffset && !thatIsOffset )
{
res = TimeZones.map( thisZone.getId() ) == TimeZones.map( thatZone.getId() );
}
else
{
res = false;
}
}
return res;
}
return false;
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldPackLocalDateTimeWithTimeZoneId()
{
LocalDateTime localDateTime = LocalDateTime.of( 1999, 12, 30, 9, 49, 20, 999999999 );
ZoneId zoneId = ZoneId.of( "Europe/Stockholm" );
ZonedDateTime zonedDateTime = ZonedDateTime.of( localDateTime, zoneId );
PackedOutputArray packedOutput = pack( datetime( zonedDateTime ) );
ByteBuffer buffer = ByteBuffer.wrap( packedOutput.bytes() );
buffer.getShort(); // skip struct header
assertEquals( INT_32, buffer.get() );
assertEquals( localDateTime.toEpochSecond( UTC ), buffer.getInt() );
assertEquals( INT_32, buffer.get() );
assertEquals( localDateTime.getNano(), buffer.getInt() );
buffer.getShort(); // skip zoneId string header
byte[] zoneIdBytes = new byte[zoneId.getId().getBytes( UTF_8 ).length];
buffer.get( zoneIdBytes );
assertEquals( zoneId.getId(), new String( zoneIdBytes, UTF_8 ) );
}
代码示例来源:origin: neo4j/neo4j
@Override
public final void writeDateTime( ZonedDateTime zonedDateTime ) throws E
{
long epochSecondUTC = zonedDateTime.toEpochSecond();
int nano = zonedDateTime.getNano();
ZoneId zone = zonedDateTime.getZone();
if ( zone instanceof ZoneOffset )
{
int offsetSeconds = ((ZoneOffset) zone).getTotalSeconds();
writeDateTime( epochSecondUTC, nano, offsetSeconds );
}
else
{
String zoneId = zone.getId();
writeDateTime( epochSecondUTC, nano, zoneId );
}
}
代码示例来源:origin: apache/hive
private static RelOptPlanner createPlanner(
HiveConf conf, Set<RelNode> corrScalarRexSQWithAgg, Set<RelNode> scalarAggNoGbyNoWin) {
final Double maxSplitSize = (double) HiveConf.getLongVar(
conf, HiveConf.ConfVars.MAPREDMAXSPLITSIZE);
final Double maxMemory = (double) HiveConf.getLongVar(
conf, HiveConf.ConfVars.HIVECONVERTJOINNOCONDITIONALTASKTHRESHOLD);
HiveAlgorithmsConf algorithmsConf = new HiveAlgorithmsConf(maxSplitSize, maxMemory);
HiveRulesRegistry registry = new HiveRulesRegistry();
Properties calciteConfigProperties = new Properties();
calciteConfigProperties.setProperty(
CalciteConnectionProperty.TIME_ZONE.camelName(),
conf.getLocalTimeZone().getId());
calciteConfigProperties.setProperty(
CalciteConnectionProperty.MATERIALIZATIONS_ENABLED.camelName(),
Boolean.FALSE.toString());
CalciteConnectionConfig calciteConfig = new CalciteConnectionConfigImpl(calciteConfigProperties);
boolean isCorrelatedColumns = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CBO_STATS_CORRELATED_MULTI_KEY_JOINS);
boolean heuristicMaterializationStrategy = HiveConf.getVar(conf,
HiveConf.ConfVars.HIVE_MATERIALIZED_VIEW_REWRITING_SELECTION_STRATEGY).equals("heuristic");
HivePlannerContext confContext = new HivePlannerContext(algorithmsConf, registry, calciteConfig,
corrScalarRexSQWithAgg, scalarAggNoGbyNoWin,
new HiveConfPlannerContext(isCorrelatedColumns, heuristicMaterializationStrategy));
return HiveVolcanoPlanner.createPlanner(confContext);
}
代码示例来源:origin: apache/hive
@Override
public void write(Kryo kryo, Output output, TimestampTZ object) {
output.writeLong(object.getEpochSecond());
output.writeInt(object.getNanos());
output.writeString(object.getZonedDateTime().getZone().getId());
}
代码示例来源:origin: OpenHFT/Chronicle-Queue
@Override
public void writeMarshallable(@NotNull WireOut wire) {
wire.write(RollFields.length).int32(length)
.write(RollFields.format).text(format)
.write(RollFields.epoch).int64(epoch);
if (rollTime != null)
wire.write(RollFields.rollTime).time(rollTime);
if (rollTimeZone != null)
wire.write(RollFields.rollTimeZone).text(rollTimeZone.getId());
}
代码示例来源:origin: prestodb/presto
@Test
public void testDate()
{
// Note: there is identical test for MySQL
ZoneId jvmZone = ZoneId.systemDefault();
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1);
verify(jvmZone.getRules().getValidOffsets(dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()).isEmpty());
ZoneId someZone = ZoneId.of("Europe/Vilnius");
LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1);
verify(someZone.getRules().getValidOffsets(dateOfLocalTimeChangeForwardAtMidnightInSomeZone.atStartOfDay()).isEmpty());
LocalDate dateOfLocalTimeChangeBackwardAtMidnightInSomeZone = LocalDate.of(1983, 10, 1);
verify(someZone.getRules().getValidOffsets(dateOfLocalTimeChangeBackwardAtMidnightInSomeZone.atStartOfDay().minusMinutes(1)).size() == 2);
DataTypeTest testCases = DataTypeTest.create()
.addRoundTrip(dateDataType(), LocalDate.of(1952, 4, 3)) // before epoch
.addRoundTrip(dateDataType(), LocalDate.of(1970, 1, 1))
.addRoundTrip(dateDataType(), LocalDate.of(1970, 2, 3))
.addRoundTrip(dateDataType(), LocalDate.of(2017, 7, 1)) // summer on northern hemisphere (possible DST)
.addRoundTrip(dateDataType(), LocalDate.of(2017, 1, 1)) // winter on northern hemisphere (possible DST on southern hemisphere)
.addRoundTrip(dateDataType(), dateOfLocalTimeChangeForwardAtMidnightInJvmZone)
.addRoundTrip(dateDataType(), dateOfLocalTimeChangeForwardAtMidnightInSomeZone)
.addRoundTrip(dateDataType(), dateOfLocalTimeChangeBackwardAtMidnightInSomeZone);
for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), jvmZone.getId(), someZone.getId())) {
Session session = Session.builder(getQueryRunner().getDefaultSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(timeZoneId))
.build();
testCases.execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_date"));
testCases.execute(getQueryRunner(), session, prestoCreateAsSelect("test_date"));
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testDate()
{
// Note: there is identical test for PostgreSQL
ZoneId jvmZone = ZoneId.systemDefault();
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1);
verify(jvmZone.getRules().getValidOffsets(dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()).isEmpty());
ZoneId someZone = ZoneId.of("Europe/Vilnius");
LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1);
verify(someZone.getRules().getValidOffsets(dateOfLocalTimeChangeForwardAtMidnightInSomeZone.atStartOfDay()).isEmpty());
LocalDate dateOfLocalTimeChangeBackwardAtMidnightInSomeZone = LocalDate.of(1983, 10, 1);
verify(someZone.getRules().getValidOffsets(dateOfLocalTimeChangeBackwardAtMidnightInSomeZone.atStartOfDay().minusMinutes(1)).size() == 2);
DataTypeTest testCases = DataTypeTest.create()
.addRoundTrip(dateDataType(), LocalDate.of(1952, 4, 3)) // before epoch
.addRoundTrip(dateDataType(), LocalDate.of(1970, 1, 1))
.addRoundTrip(dateDataType(), LocalDate.of(1970, 2, 3))
.addRoundTrip(dateDataType(), LocalDate.of(2017, 7, 1)) // summer on northern hemisphere (possible DST)
.addRoundTrip(dateDataType(), LocalDate.of(2017, 1, 1)) // winter on northern hemisphere (possible DST on southern hemisphere)
.addRoundTrip(dateDataType(), dateOfLocalTimeChangeForwardAtMidnightInJvmZone)
.addRoundTrip(dateDataType(), dateOfLocalTimeChangeForwardAtMidnightInSomeZone)
.addRoundTrip(dateDataType(), dateOfLocalTimeChangeBackwardAtMidnightInSomeZone);
for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), jvmZone.getId(), someZone.getId())) {
Session session = Session.builder(getQueryRunner().getDefaultSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(timeZoneId))
.build();
testCases.execute(getQueryRunner(), session, mysqlCreateAndInsert("tpch.test_date"));
testCases.execute(getQueryRunner(), session, prestoCreateAsSelect("test_date"));
}
}
代码示例来源:origin: neo4j/neo4j
public static byte[] encodeDateTimeArray( ZonedDateTime[] dateTimes )
{
// We could store this in dateTimes.length * 2.5 if we wanted
long[] data = new long[dateTimes.length * BLOCKS_DATETIME];
int i;
for ( i = 0; i < dateTimes.length; i++ )
{
data[i * BLOCKS_DATETIME] = dateTimes[i].toEpochSecond();
data[i * BLOCKS_DATETIME + 1] = dateTimes[i].getNano();
if ( dateTimes[i].getZone() instanceof ZoneOffset )
{
ZoneOffset offset = (ZoneOffset) dateTimes[i].getZone();
int secondOffset = offset.getTotalSeconds();
// Set lowest bit to 1 means offset
data[i * BLOCKS_DATETIME + 2] = secondOffset << 1 | 1L;
}
else
{
String timeZoneId = dateTimes[i].getZone().getId();
short zoneNumber = TimeZones.map( timeZoneId );
// Set lowest bit to 0 means zone id
data[i * BLOCKS_DATETIME + 2] = zoneNumber << 1;
}
}
TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DATE_TIME.temporalType );
byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE );
header.writeArrayHeaderTo( bytes );
return bytes;
}
代码示例来源:origin: neo4j/neo4j
@Override
public void writeDateTime( ZonedDateTime zonedDateTime ) throws IOException
{
long epochSecondLocal = zonedDateTime.toLocalDateTime().toEpochSecond( UTC );
int nano = zonedDateTime.getNano();
ZoneId zone = zonedDateTime.getZone();
if ( zone instanceof ZoneOffset )
{
int offsetSeconds = ((ZoneOffset) zone).getTotalSeconds();
packStructHeader( DATE_TIME_WITH_ZONE_OFFSET_SIZE, DATE_TIME_WITH_ZONE_OFFSET );
pack( epochSecondLocal );
pack( nano );
pack( offsetSeconds );
}
else
{
String zoneId = zone.getId();
packStructHeader( DATE_TIME_WITH_ZONE_NAME_SIZE, DATE_TIME_WITH_ZONE_NAME );
pack( epochSecondLocal );
pack( nano );
pack( zoneId );
}
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void write( Object value, FlushableChannel into ) throws IOException
{
ZonedDateTime zonedDateTime = (ZonedDateTime) value;
long epochSecondUTC = zonedDateTime.toEpochSecond();
int nano = zonedDateTime.getNano();
ZoneId zone = zonedDateTime.getZone();
if ( zone instanceof ZoneOffset )
{
int offsetSeconds = ((ZoneOffset) zone).getTotalSeconds();
into.put( (byte) 0 );
into.putLong( epochSecondUTC );
into.putInt( nano );
into.putInt( offsetSeconds );
}
else
{
String zoneId = zone.getId();
into.put( (byte) 1 );
into.putLong( epochSecondUTC );
into.putInt( nano );
into.putInt( TimeZones.map( zoneId ) );
}
}
} );
在尝试 time 的 python 执行时,我发现在一条语句中两次调用 time.time() 时出现奇怪的行为。在语句执行期间获取time.time() 有一个非常小的处理延迟。 例如time.ti
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我不明白为什么下面的结果是一样的。我预计第一个结果是指针地址。 func print(t *time.Time) { fmt.Println(t) // 2009-11-10 23:00:00
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32 Type "help
当我有一个time.Time时: // January, 29th t, _ := time.Parse("2006-01-02", "2016-01-29") 如何获得代表 1 月 31 日的 ti
首先,我意识到不推荐使用 time with time zone。我要使用它是因为我将多个 time with time zone 值与我当前的系统时间进行比较,而不管是哪一天。 IE。用户说每天 0
长期以来,在 Rust 中精确测量时间的标准方法是 time crate 及其 time::precise_time_ns功能。但是,time crate 现在已被弃用,std 库有 std::tim
我正在我学校的一个科学集群上运行我的有限差分程序。该程序使用 openmpi 来并行化代码。 当程序连续运行时,我得到: real 78m40.592s user 78m34.920s s
尽管它们已被弃用并且有比 time 更好的模块(即 timeit),但我想知道这两个函数 time 之间的区别.clock() 和 time.time()。 从后者 (time.time()) 开始,
这个问题在这里已经有了答案: Python's time.clock() vs. time.time() accuracy? (16 个答案) 关闭 6 年前。 我认为两者都衡量时间量?但是他们返回
我正在尝试测试 http 请求处理代码块在我的 Flask Controller 中需要多长时间,这是我使用的示例代码: cancelled = [] t0 = time.time() t1 = ti
运行 python 的计算机时钟(Windows 或 Linux)时会发生什么自动更改并调用 time.time()? 我读到,当时钟手动更改为过去的某个值时,time.time() 的值会变小。 最
我有一个结构可能无法在其字段之一上设置 time.Time 值。测试无效性时,我不能使用 nil 或 0。time.Unix(0,0) 也不相同。我想到了这个: var emptyTime time.
我有一个打算用数据库记录填充的结构,其中一个日期时间列可以为空: type Reminder struct { Id int CreatedAt time.Time
问题陈述:通过匹配其百分比随机执行各种命令。比如执行 CommandA 50% 的时间和 commandB 25% 的时间和 commandC 15% 的时间等等,总百分比应该是 100%。 我的问题
我正在使用 laravel 6。我在同一个应用程序中有类似的 Controller 和类似的 View ,它工作正常。对比之后还是找不到错误。 Facade\Ignition\Exceptions\V
我需要用 ("%m/%d/%Y %H:%M:%S") 格式表示时间,我得到的浮点值是 time.time(). 我已经有了一个 time.time() 形式的值。例如,我已经有一个值,我每 0.3 秒
我正在使用以下方法获取 utc 日期时间: import datetime import time from pytz import timezone now_utc = datetime.datet
我在 Ubuntu 上使用 time.clock 和 time.time 为一段 python 代码计时: clock elapsed time: 8.770 s time elapsed time
我是一名优秀的程序员,十分优秀!