org.apache.calcite.util.Util.toPosix()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(161)

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

Util.toPosix介绍

[英]Converts a Java timezone to POSIX format, so that the boost C++ library can instantiate timezone objects.

POSIX IEEE 1003.1 defines a format for timezone specifications.

The boost C++ library can read these specifications and instantiate posix_time_zone objects from them. The purpose of this method, therefore, is to allow the C++ code such as the fennel calculator to use the same notion of timezone as Java code.

The format is as follows:
"std offset dst [offset],start[/time],end[/time]"

where:

  • 'std' specifies the abbrev of the time zone.
  • 'offset' is the offset from UTC, and takes the form [+|-]hh[:mm[:ss]] {h=0-23, m/s=0-59}
  • 'dst' specifies the abbrev of the time zone during daylight savings time
  • The second offset is how many hours changed during DST. Default=1
  1. 'start' and 'end' are the dates when DST goes into (and out of) effect.

They can each be one of three forms:

  1. Mm.w.d {month=1-12, week=1-5 (5 is always last), day=0-6}
    1. Jn {n=1-365 Feb29 is never counted}
    2. n {n=0-365 Feb29 is counted in leap years}
  2. 'time' has the same format as 'offset', and defaults to 02:00:00.

For example:

  • "PST-8PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00"; or more tersely
  • "PST-8PDT,M4.1.0,M10.1.0"

(Real format strings do not contain spaces; they are in the above template only for readability.)

Boost apparently diverges from the POSIX standard in how it treats the sign of timezone offsets. The POSIX standard states 'If preceded by a '-', the timezone shall be east of the Prime Meridian; otherwise, it shall be west', yet boost requires the opposite. For instance, PST has offset '-8' above. This method generates timezone strings consistent with boost's expectations.
[中]将java时区转换为POSIX格式,以便Boost C库可以实例化时区对象。
POSIX IEEE 1003.1定义了时区规范的格式。
Boost C
库可以读取这些规范并从它们实例化{{$$ 1 $}}对象。因此,该方法的目的是允许C++代码,如茴香计算器使用与java代码相同的时区概念。
格式如下:
标准偏移量dst[offset],开始时间,结束时间
哪里:
*“std”指定时区的缩写。
*“偏移量”是与UTC的偏移量,其形式为[+|-]hh[:mm[:ss]] {h=0-23, m/s=0-59}
*“dst”指定夏令时期间时区的缩写
*第二个偏移量是DST期间更改了多少小时。默认值=1
1.“开始”和“结束”是DST生效(和失效)的日期。
它们可以是三种形式中的一种:
1.嗯。w、 d{month=1-12,week=1-5(5总是最后一个),day=0-6}
1.Jn{n=1-365二月29日从不计算}
1.n{n=0-365二月29日以闰年计算}
1.“时间”的格式与“偏移量”相同,默认为02:00:00。
例如:
*“PST-8PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00”;或者更简洁
*“PST-8PDT,M4.1.0,M10.1.0”
(实格式字符串不包含空格;它们在上述模板中仅用于可读性。)
Boost在处理时区偏移符号的方式上明显不同于POSIX标准。POSIX标准规定,“如果前面有“-”,则时区应位于本初子午线以东;否则,它将是“西部”,但推进需要相反的东西。例如,PST上面有偏移量'-8'。这种方法生成的时区字符串符合boost的预期。

代码示例

代码示例来源:origin: Qihoo360/Quicksql

Util.toPosix(TimeZone.getTimeZone("PST"), true));
Util.toPosix(TimeZone.getTimeZone("Asia/Tokyo"), true));
Util.toPosix(TimeZone.getTimeZone("Australia/Sydney"), true);
Util.toPosix(TimeZone.getTimeZone("Europe/Paris"), true));
Util.toPosix(TimeZone.getTimeZone("UTC"), true));

代码示例来源:origin: org.apache.calcite/calcite-core

Util.toPosix(TimeZone.getTimeZone("PST"), true));
Util.toPosix(TimeZone.getTimeZone("Asia/Tokyo"), true));
Util.toPosix(TimeZone.getTimeZone("Australia/Sydney"), true);
Util.toPosix(TimeZone.getTimeZone("Europe/Paris"), true));
Util.toPosix(TimeZone.getTimeZone("UTC"), true));

相关文章