Java Code Examples for java.time.ZoneOffset#UTC
The following examples show how to use
java.time.ZoneOffset#UTC .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKZoneIdPrinterParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="parseSuccess") Object[][] data_parseSuccess() { return new Object[][] { {"Z", 1, -1, ZoneId.of("Z")}, {"UTC", 3, -1, ZoneId.of("UTC")}, {"UT", 2, -1, ZoneId.of("UT")}, {"GMT", 3, -1, ZoneId.of("GMT")}, {"+00:00", 6, -1, ZoneOffset.UTC}, {"UTC+00:00", 9, -1, ZoneId.of("UTC")}, {"UT+00:00", 8, -1, ZoneId.of("UT")}, {"GMT+00:00", 9, -1, ZoneId.of("GMT")}, {"-00:00", 6, -1, ZoneOffset.UTC}, {"UTC-00:00", 9, -1, ZoneId.of("UTC")}, {"UT-00:00", 8, -1, ZoneId.of("UT")}, {"GMT-00:00", 9, -1, ZoneId.of("GMT")}, {"+01:30", 6, -1, ZoneOffset.ofHoursMinutes(1, 30)}, {"UTC+01:30", 9, -1, ZoneId.of("UTC+01:30")}, {"UT+02:30", 8, -1, ZoneId.of("UT+02:30")}, {"GMT+03:30", 9, -1, ZoneId.of("GMT+03:30")}, {"-01:30", 6, -1, ZoneOffset.ofHoursMinutes(-1, -30)}, {"UTC-01:30", 9, -1, ZoneId.of("UTC-01:30")}, {"UT-02:30", 8, -1, ZoneId.of("UT-02:30")}, {"GMT-03:30", 9, -1, ZoneId.of("GMT-03:30")}, // fallback to UTC {"UTC-01:WW", 3, -1, ZoneId.of("UTC")}, {"UT-02:WW", 2, -1, ZoneId.of("UT")}, {"GMT-03:WW", 3, -1, ZoneId.of("GMT")}, {"Z0", 1, -1, ZoneOffset.UTC}, {"UTC1", 3, -1, ZoneId.of("UTC")}, // Z not parsed as zero {"UTCZ", 3, -1, ZoneId.of("UTC")}, {"UTZ", 2, -1, ZoneId.of("UT")}, {"GMTZ", 3, -1, ZoneId.of("GMT")}, // 0 not parsed {"UTC0", 3, -1, ZoneId.of("UTC")}, {"UT0", 2, -1, ZoneId.of("UT")}, // fail to parse {"", 0, 0, null}, {"A", 0, 0, null}, {"UZ", 0, 0, null}, {"GMA", 0, 0, null}, {"0", 0, 0, null}, {"+", 0, 0, null}, {"-", 0, 0, null}, // zone IDs {"Europe/London", 13, -1, ZoneId.of("Europe/London")}, {"America/New_York", 16, -1, ZoneId.of("America/New_York")}, {"America/Bogusville", 0, 0, null}, }; }
Example 2
Source File: TimestampToVarcharCast.java From presto with Apache License 2.0 | 6 votes |
@LiteralParameters({"x", "p"}) @SqlType("varchar(x)") public static Slice cast(@LiteralParameter("p") long precision, ConnectorSession session, @SqlType("timestamp(p)") long timestamp) { long epochMicros = timestamp; if (precision <= 3) { epochMicros = scaleEpochMillisToMicros(timestamp); } ZoneId zoneId = ZoneOffset.UTC; if (session.isLegacyTimestamp()) { zoneId = session.getTimeZoneKey().getZoneId(); } return utf8Slice(Timestamps.formatTimestamp((int) precision, epochMicros, 0, zoneId, TIMESTAMP_FORMATTER)); }
Example 3
Source File: TCKZoneOffset.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_getId() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0); assertEquals(offset.getId(), "+01:00"); offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); assertEquals(offset.getId(), "+01:02:03"); offset = ZoneOffset.UTC; assertEquals(offset.getId(), "Z"); }
Example 4
Source File: TCKZoneOffset.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_getId() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0); assertEquals(offset.getId(), "+01:00"); offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); assertEquals(offset.getId(), "+01:02:03"); offset = ZoneOffset.UTC; assertEquals(offset.getId(), "Z"); }
Example 5
Source File: ParseDateFieldUpdateProcessorFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void init(@SuppressWarnings({"rawtypes"})NamedList args) { Locale locale; String localeParam = (String)args.remove(LOCALE_PARAM); if (null != localeParam) { locale = LocaleUtils.toLocale(localeParam); } else { locale = Locale.US; // because well-known patterns assume this } Object defaultTimeZoneParam = args.remove(DEFAULT_TIME_ZONE_PARAM); ZoneId defaultTimeZone = ZoneOffset.UTC; if (null != defaultTimeZoneParam) { defaultTimeZone = ZoneId.of(defaultTimeZoneParam.toString()); } @SuppressWarnings({"unchecked"}) Collection<String> formatsParam = args.removeConfigArgs(FORMATS_PARAM); if (null != formatsParam) { for (String value : formatsParam) { DateTimeFormatter formatter = new DateTimeFormatterBuilder().parseLenient().parseCaseInsensitive() .appendPattern(value).toFormatter(locale) .withResolverStyle(ResolverStyle.LENIENT).withZone(defaultTimeZone); validateFormatter(formatter); formats.put(value, formatter); } } super.init(args); }
Example 6
Source File: TCKZoneRules.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public void test_of(){ //used for standard offset ZoneOffset stdOffset1 = ZoneOffset.UTC; ZoneOffset stdOffset2 = ZoneOffset.ofHours(1); LocalDateTime time_of_stdOffsetTransition1 = LocalDateTime.of(2013, 1, 5, 1, 0); ZoneOffsetTransition stdOffsetTransition1 = ZoneOffsetTransition.of(time_of_stdOffsetTransition1, stdOffset1, stdOffset2); List<ZoneOffsetTransition> stdOffsetTransition_list = new ArrayList<ZoneOffsetTransition>(); stdOffsetTransition_list.add(stdOffsetTransition1); //used for wall offset ZoneOffset wallOffset1 = ZoneOffset.ofHours(2); ZoneOffset wallOffset2 = ZoneOffset.ofHours(4); ZoneOffset wallOffset3 = ZoneOffset.ofHours(7); LocalDateTime time_of_wallOffsetTransition1 = LocalDateTime.of(2013, 2, 5, 1, 0); LocalDateTime time_of_wallOffsetTransition2 = LocalDateTime.of(2013, 3, 5, 1, 0); LocalDateTime time_of_wallOffsetTransition3 = LocalDateTime.of(2013, 10, 5, 1, 0); ZoneOffsetTransition wallOffsetTransition1 = ZoneOffsetTransition.of(time_of_wallOffsetTransition1, wallOffset1, wallOffset2); ZoneOffsetTransition wallOffsetTransition2 = ZoneOffsetTransition.of(time_of_wallOffsetTransition2, wallOffset2, wallOffset3); ZoneOffsetTransition wallOffsetTransition3 = ZoneOffsetTransition.of(time_of_wallOffsetTransition3, wallOffset3, wallOffset1); List<ZoneOffsetTransition> wallOffsetTransition_list = new ArrayList<ZoneOffsetTransition>(); wallOffsetTransition_list.add(wallOffsetTransition1); wallOffsetTransition_list.add(wallOffsetTransition2); wallOffsetTransition_list.add(wallOffsetTransition3); //used for ZoneOffsetTransitionRule ZoneOffset ruleOffset = ZoneOffset.ofHours(3); ZoneOffsetTransitionRule.TimeDefinition timeDefinition = ZoneOffsetTransitionRule.TimeDefinition.valueOf("WALL"); ZoneOffsetTransitionRule rule1 = ZoneOffsetTransitionRule.of(Month.FEBRUARY, 2, DayOfWeek.MONDAY, LocalTime.of(1, 0), false, timeDefinition, ZoneOffset.UTC, ZoneOffset.UTC, ruleOffset ); List<ZoneOffsetTransitionRule> rule_list = new ArrayList<ZoneOffsetTransitionRule>(); rule_list.add(rule1); //Begin verification ZoneRules zoneRule = ZoneRules.of(stdOffset1, wallOffset1, stdOffsetTransition_list, wallOffsetTransition_list, rule_list ); OffsetDateTime before_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).minusSeconds(1); OffsetDateTime after_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).plusSeconds(1);; assertEquals(zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant()), stdOffset1); assertEquals(zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant()), stdOffset2); OffsetDateTime before_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition1); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition2); OffsetDateTime before_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition2); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition3); OffsetDateTime before_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant()), wallOffsetTransition3); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant()), rule1.createTransition(2014)); }
Example 7
Source File: TCKZoneOffset.java From j2objc with Apache License 2.0 | 4 votes |
@Test public void test_constant_UTC() { ZoneOffset test = ZoneOffset.UTC; doTestOffset(test, 0, 0, 0); }
Example 8
Source File: TestZoneOffsetPrinter.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "NO-OFFSET", ZoneOffset.UTC}, {"+HH", "+01", ZoneOffset.ofHours(1)}, {"+HH", "-01", ZoneOffset.ofHours(-1)}, {"+HHMM", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMM", "+0102", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HHMM", "-0102", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HH:MM", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM", "+01:02", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HH:MM", "-01:02", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HHMMss", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+0102", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HHMMss", "+0159", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "+010215", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMss", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMss", "+015959", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:ss", "+01:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "+01:02:15", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:ss", "+01:59:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMSS", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMSS", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMSS", "-010203", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HHMMSS", "+010200", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HHMMSS", "-010200", ZoneOffset.ofHoursMinutesSeconds(-1, -2, 0)}, {"+HH:MM:SS", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:SS", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:SS", "-01:02:03", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HH:MM:SS", "+01:02:00", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:SS", "-01:02:00", ZoneOffset.ofHoursMinutesSeconds(-1, -2, 0)}, }; }
Example 9
Source File: TestZoneOffsetParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "+00", ZoneOffset.UTC}, {"+HH", "-00", ZoneOffset.UTC}, {"+HH", "+01", ZoneOffset.ofHours(1)}, {"+HH", "-01", ZoneOffset.ofHours(-1)}, {"+HHMM", "+0000", ZoneOffset.UTC}, {"+HHMM", "-0000", ZoneOffset.UTC}, {"+HHMM", "+0102", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HHMM", "-0102", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HH:MM", "+00:00", ZoneOffset.UTC}, {"+HH:MM", "-00:00", ZoneOffset.UTC}, {"+HH:MM", "+01:02", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HH:MM", "-01:02", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HHMMss", "+0000", ZoneOffset.UTC}, {"+HHMMss", "-0000", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+0159", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "+010215", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMss", "+000000", ZoneOffset.UTC}, {"+HHMMss", "-000000", ZoneOffset.UTC}, {"+HHMMss", "+010000", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMss", "+015959", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HHMMss", "+020000", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+180000", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "-010000", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-020000", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-180000", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "+00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "-00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:ss", "+01:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "+01:02:15", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "+00:00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "-00:00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:ss", "+01:59:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HH:MM:ss", "+02:00:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "-01:00:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMSS", "+000000", ZoneOffset.UTC}, {"+HHMMSS", "-000000", ZoneOffset.UTC}, {"+HHMMSS", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMSS", "-010203", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HH:MM:SS", "+00:00:00", ZoneOffset.UTC}, {"+HH:MM:SS", "-00:00:00", ZoneOffset.UTC}, {"+HH:MM:SS", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:SS", "-01:02:03", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, }; }
Example 10
Source File: Schedule.java From dremio-oss with Apache License 2.0 | 4 votes |
private Builder(TemporalAmount amount, TemporalAdjuster adjuster) { this(Instant.now(), amount, adjuster, ZoneOffset.UTC); }
Example 11
Source File: TCKZoneIdPrinterParser.java From hottub with GNU General Public License v2.0 | 4 votes |
@DataProvider(name="parseSuccess") Object[][] data_parseSuccess() { return new Object[][] { {"Z", 1, -1, ZoneId.of("Z")}, {"UTC", 3, -1, ZoneId.of("UTC")}, {"UT", 2, -1, ZoneId.of("UT")}, {"GMT", 3, -1, ZoneId.of("GMT")}, {"+00:00", 6, -1, ZoneOffset.UTC}, {"UTC+00:00", 9, -1, ZoneId.of("UTC")}, {"UT+00:00", 8, -1, ZoneId.of("UT")}, {"GMT+00:00", 9, -1, ZoneId.of("GMT")}, {"-00:00", 6, -1, ZoneOffset.UTC}, {"UTC-00:00", 9, -1, ZoneId.of("UTC")}, {"UT-00:00", 8, -1, ZoneId.of("UT")}, {"GMT-00:00", 9, -1, ZoneId.of("GMT")}, {"+01:30", 6, -1, ZoneOffset.ofHoursMinutes(1, 30)}, {"UTC+01:30", 9, -1, ZoneId.of("UTC+01:30")}, {"UT+02:30", 8, -1, ZoneId.of("UT+02:30")}, {"GMT+03:30", 9, -1, ZoneId.of("GMT+03:30")}, {"-01:30", 6, -1, ZoneOffset.ofHoursMinutes(-1, -30)}, {"UTC-01:30", 9, -1, ZoneId.of("UTC-01:30")}, {"UT-02:30", 8, -1, ZoneId.of("UT-02:30")}, {"GMT-03:30", 9, -1, ZoneId.of("GMT-03:30")}, // fallback to UTC {"UTC-01:WW", 3, -1, ZoneId.of("UTC")}, {"UT-02:WW", 2, -1, ZoneId.of("UT")}, {"GMT-03:WW", 3, -1, ZoneId.of("GMT")}, {"Z0", 1, -1, ZoneOffset.UTC}, {"UTC1", 3, -1, ZoneId.of("UTC")}, // Z not parsed as zero {"UTCZ", 3, -1, ZoneId.of("UTC")}, {"UTZ", 2, -1, ZoneId.of("UT")}, {"GMTZ", 3, -1, ZoneId.of("GMT")}, // 0 not parsed {"UTC0", 3, -1, ZoneId.of("UTC")}, {"UT0", 2, -1, ZoneId.of("UT")}, // fail to parse {"", 0, 0, null}, {"A", 0, 0, null}, {"UZ", 0, 0, null}, {"GMA", 0, 0, null}, {"0", 0, 0, null}, {"+", 0, 0, null}, {"-", 0, 0, null}, // zone IDs {"Europe/London", 13, -1, ZoneId.of("Europe/London")}, {"America/New_York", 16, -1, ZoneId.of("America/New_York")}, {"America/Bogusville", 0, 0, null}, }; }
Example 12
Source File: SimpleLogHandlerTest.java From bazel with Apache License 2.0 | 4 votes |
@Test public void testTotalLimit() throws Exception { String username = System.getProperty("user.name"); if (Strings.isNullOrEmpty(username)) { username = "unknown_user"; } String hostname = SimpleLogHandler.getLocalHostnameFirstComponent(); String baseFilename = "hello." + hostname + "." + username + ".log.java."; Path nonLog = newFileOfSize("non_log", 16); Path missingDate = newFileOfSize(baseFilename + ".123", 16); Path invalidExtension = newFileOfSize(baseFilename + "19900101-120000.invalid", 16); Path oldDeleted1 = newFileOfSize(baseFilename + "19900101-120000.123", 16); Path oldDeleted2 = newFileOfSize(baseFilename + "19950101-120000.123", 16); Path keptThenDeleted = newFileOfSize(baseFilename + "19990101-120000.123", 16); Path kept = newFileOfSize(baseFilename + "19990606-060000.123", 16); FakeClock clock = new FakeClock(Instant.parse("2018-01-01T12:00:00Z"), ZoneOffset.UTC); SimpleLogHandler handler = SimpleLogHandler.builder() .setPrefix(tmp.getRoot() + File.separator + "hello") .setPattern(".%h.%u.log.java.") .setFormatter(new TrivialFormatter()) .setRotateLimitBytes(16) .setTotalLimitBytes(40) .setClockForTesting(clock) .build(); // Print 8 bytes into the log file. Opening the log file triggers deletion of old logs. handler.publish(new LogRecord(Level.SEVERE, "1234567" /* 8 bytes including "\n" */)); // We expect handler to delete all but 32 = 40 - 8 bytes worth of old log files. assertThat(Files.exists(nonLog)).isTrue(); assertThat(Files.exists(missingDate)).isTrue(); assertThat(Files.exists(invalidExtension)).isTrue(); assertThat(Files.exists(oldDeleted1)).isFalse(); assertThat(Files.exists(oldDeleted2)).isFalse(); assertThat(Files.exists(keptThenDeleted)).isTrue(); assertThat(Files.exists(kept)).isTrue(); handler.publish(new LogRecord(Level.SEVERE, "1234567" /* 8 bytes including "\n" */)); Path currentLogPath = handler.getCurrentLogFilePath().get(); handler.close(); // We expect another old log file to be deleted after rotation. assertThat(Files.exists(keptThenDeleted)).isFalse(); assertThat(Files.exists(kept)).isTrue(); assertThat(Files.exists(currentLogPath)).isTrue(); }
Example 13
Source File: TwoPhaseCommitSinkFunctionTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private SettableClock() { this.zoneId = ZoneOffset.UTC; }
Example 14
Source File: TCKZoneIdPrinterParser.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@DataProvider(name="parseSuccess") Object[][] data_parseSuccess() { return new Object[][] { {"Z", 1, -1, ZoneId.of("Z")}, {"UTC", 3, -1, ZoneId.of("UTC")}, {"UT", 2, -1, ZoneId.of("UT")}, {"GMT", 3, -1, ZoneId.of("GMT")}, {"+00:00", 6, -1, ZoneOffset.UTC}, {"UTC+00:00", 9, -1, ZoneId.of("UTC")}, {"UT+00:00", 8, -1, ZoneId.of("UT")}, {"GMT+00:00", 9, -1, ZoneId.of("GMT")}, {"-00:00", 6, -1, ZoneOffset.UTC}, {"UTC-00:00", 9, -1, ZoneId.of("UTC")}, {"UT-00:00", 8, -1, ZoneId.of("UT")}, {"GMT-00:00", 9, -1, ZoneId.of("GMT")}, {"+01:30", 6, -1, ZoneOffset.ofHoursMinutes(1, 30)}, {"UTC+01:30", 9, -1, ZoneId.of("UTC+01:30")}, {"UT+02:30", 8, -1, ZoneId.of("UT+02:30")}, {"GMT+03:30", 9, -1, ZoneId.of("GMT+03:30")}, {"-01:30", 6, -1, ZoneOffset.ofHoursMinutes(-1, -30)}, {"UTC-01:30", 9, -1, ZoneId.of("UTC-01:30")}, {"UT-02:30", 8, -1, ZoneId.of("UT-02:30")}, {"GMT-03:30", 9, -1, ZoneId.of("GMT-03:30")}, // fallback to UTC {"UTC-01:WW", 3, -1, ZoneId.of("UTC")}, {"UT-02:WW", 2, -1, ZoneId.of("UT")}, {"GMT-03:WW", 3, -1, ZoneId.of("GMT")}, {"Z0", 1, -1, ZoneOffset.UTC}, {"UTC1", 3, -1, ZoneId.of("UTC")}, // Z not parsed as zero {"UTCZ", 3, -1, ZoneId.of("UTC")}, {"UTZ", 2, -1, ZoneId.of("UT")}, {"GMTZ", 3, -1, ZoneId.of("GMT")}, // 0 not parsed {"UTC0", 3, -1, ZoneId.of("UTC")}, {"UT0", 2, -1, ZoneId.of("UT")}, // fail to parse {"", 0, 0, null}, {"A", 0, 0, null}, {"UZ", 0, 0, null}, {"GMA", 0, 0, null}, {"0", 0, 0, null}, {"+", 0, 0, null}, {"-", 0, 0, null}, // zone IDs {"Europe/London", 13, -1, ZoneId.of("Europe/London")}, {"America/New_York", 16, -1, ZoneId.of("America/New_York")}, {"America/Bogusville", 0, 0, null}, }; }
Example 15
Source File: EpochMillisDateFormatter.java From crate with Apache License 2.0 | 4 votes |
@Override public ZoneId getZone() { return ZoneOffset.UTC; }
Example 16
Source File: TestZoneOffsetPrinter.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "NO-OFFSET", ZoneOffset.UTC}, {"+HH", "+01", ZoneOffset.ofHours(1)}, {"+HH", "-01", ZoneOffset.ofHours(-1)}, {"+HHMM", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMM", "+0102", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HHMM", "-0102", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HH:MM", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM", "+01:02", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HH:MM", "-01:02", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HHMMss", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+0102", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HHMMss", "+0159", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "+010215", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMss", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMss", "+015959", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:ss", "+01:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "+01:02:15", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:ss", "+01:59:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMSS", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMSS", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMSS", "-010203", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HHMMSS", "+010200", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HHMMSS", "-010200", ZoneOffset.ofHoursMinutesSeconds(-1, -2, 0)}, {"+HH:MM:SS", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:SS", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:SS", "-01:02:03", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HH:MM:SS", "+01:02:00", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:SS", "-01:02:00", ZoneOffset.ofHoursMinutesSeconds(-1, -2, 0)}, }; }
Example 17
Source File: MultipathPolicyTracker.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public Clock getClock() { return new BestClock(ZoneOffset.UTC, SystemClock.currentNetworkTimeClock(), Clock.systemUTC()); }
Example 18
Source File: EpochSecondsDateFormatter.java From crate with Apache License 2.0 | 4 votes |
@Override public ZoneId getZone() { return ZoneOffset.UTC; }
Example 19
Source File: InstantColumnFormatter.java From tablesaw with Apache License 2.0 | 4 votes |
public InstantColumnFormatter() { this.format = null; this.zoneId = ZoneOffset.UTC; }
Example 20
Source File: Db2ValueConverters.java From debezium-incubator with Apache License 2.0 | 2 votes |
/** * Create a new instance that always uses UTC for the default time zone when * converting values without timezone information to values that require * timezones. * <p> * * @param decimalMode * how {@code DECIMAL} and {@code NUMERIC} values should be * treated; may be null if * {@link io.debezium.jdbc.JdbcValueConverters.DecimalMode#PRECISE} * is to be used * @param temporalPrecisionMode * date/time value will be represented either as Connect datatypes or Debezium specific datatypes */ public Db2ValueConverters(DecimalMode decimalMode, TemporalPrecisionMode temporalPrecisionMode) { super(decimalMode, temporalPrecisionMode, ZoneOffset.UTC, null, null, null); }