List of usage examples for java.time ZoneId systemDefault
public static ZoneId systemDefault()
From source file:com.splicemachine.orc.OrcTester.java
private static Object preprocessWriteValueOld(TypeInfo typeInfo, Object value) throws IOException { if (value == null) { return null; }/* w w w . ja va 2s . c o m*/ switch (typeInfo.getCategory()) { case PRIMITIVE: PrimitiveObjectInspector.PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo) .getPrimitiveCategory(); switch (primitiveCategory) { case BOOLEAN: return value; case BYTE: return ((Number) value).byteValue(); case SHORT: return ((Number) value).shortValue(); case INT: return ((Number) value).intValue(); case LONG: return ((Number) value).longValue(); case FLOAT: return ((Number) value).floatValue(); case DOUBLE: return ((Number) value).doubleValue(); case DECIMAL: return HiveDecimal.create(((Decimal) value).toBigDecimal().bigDecimal()); case STRING: return value; case CHAR: return new HiveChar(value.toString(), ((CharTypeInfo) typeInfo).getLength()); case DATE: LocalDate localDate = LocalDate.ofEpochDay((int) value); ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault()); long millis = zonedDateTime.toEpochSecond() * 1000; Date date = new Date(0); // mills must be set separately to avoid masking date.setTime(millis); return date; case TIMESTAMP: long millisUtc = ((Long) value).intValue(); return new Timestamp(millisUtc); case BINARY: return ((String) value).getBytes(); // return (byte[])value; } break; case MAP: MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo; TypeInfo keyTypeInfo = mapTypeInfo.getMapKeyTypeInfo(); TypeInfo valueTypeInfo = mapTypeInfo.getMapValueTypeInfo(); Map<Object, Object> newMap = new HashMap<>(); for (Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) { newMap.put(preprocessWriteValueOld(keyTypeInfo, entry.getKey()), preprocessWriteValueOld(valueTypeInfo, entry.getValue())); } return newMap; case LIST: ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; TypeInfo elementTypeInfo = listTypeInfo.getListElementTypeInfo(); List<Object> newList = new ArrayList<>(((Collection<?>) value).size()); for (Object element : (Iterable<?>) value) { newList.add(preprocessWriteValueOld(elementTypeInfo, element)); } return newList; case STRUCT: StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo; List<?> fieldValues = (List<?>) value; List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos(); List<Object> newStruct = new ArrayList<>(); for (int fieldId = 0; fieldId < fieldValues.size(); fieldId++) { newStruct.add(preprocessWriteValueOld(fieldTypeInfos.get(fieldId), fieldValues.get(fieldId))); } return newStruct; } throw new IOException(format("Unsupported Hive type: %s", typeInfo)); }
From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java
@Test public void durationReminderOnSeveralDaysEventOf2HoursShouldWork() throws Exception { final DurationReminder durationReminder = initReminderBuilder( setupSeveralDaysEventOn2Hours(ZoneId.systemDefault())).triggerBefore(0, TimeUnit.MINUTE, ""); triggerDateTime(durationReminder);//from www . java 2 s . co m final Map<String, String> titles = computeNotificationTitles(durationReminder); assertThat(titles.get(DE), is("Reminder about the event super test - 21.02.2018 23:00 - 22.02.2018 01:00")); assertThat(titles.get(EN), is("Reminder about the event super test - 02/21/2018 23:00 - 02/22/2018 01:00")); assertThat(titles.get(FR), is("Rappel sur l'vnement super test - 21/02/2018 23:00 - 22/02/2018 01:00")); final Map<String, String> contents = computeNotificationContents(durationReminder); assertThat(contents.get(DE), is( "REMINDER: The event <b>super test</b> will be from 21.02.2018 at 23:00 to 22.02.2018 at 01:00.")); assertThat(contents.get(EN), is( "REMINDER: The event <b>super test</b> will be from 02/21/2018 at 23:00 to 02/22/2018 at 01:00.")); assertThat(contents.get(FR), is( "RAPPEL : L'vnement <b>super test</b> aura lieu du 21/02/2018 23:00 au 22/02/2018 01:00.")); }
From source file:org.tightblog.service.WeblogEntryManager.java
/** * Get Weblog Entries grouped by calendar day. * * @param wesc WeblogEntrySearchCriteria object listing desired search parameters * @return Map of Lists of WeblogEntries keyed by calendar day *///from www .jav a2 s.co m public Map<LocalDate, List<WeblogEntry>> getDateToWeblogEntryMap(WeblogEntrySearchCriteria wesc) { Map<LocalDate, List<WeblogEntry>> map = new TreeMap<>(Collections.reverseOrder()); List<WeblogEntry> entries = getWeblogEntries(wesc); for (WeblogEntry entry : entries) { entry.setCommentRepository(weblogEntryCommentRepository); LocalDate tmp = entry.getPubTime() == null ? LocalDate.now() : entry.getPubTime().atZone(ZoneId.systemDefault()).toLocalDate(); List<WeblogEntry> dayEntries = map.computeIfAbsent(tmp, k -> new ArrayList<>()); dayEntries.add(entry); } return map; }
From source file:org.apache.nifi.processors.solr.SolrUtils.java
private static LocalDate getLocalDateFromEpochTime(String fieldName, Object coercedValue) { Long date = DataTypeUtils.toLong(coercedValue, fieldName); return Instant.ofEpochMilli(date).atZone(ZoneId.systemDefault()).toLocalDate(); }
From source file:org.apache.nifi.processors.solr.SolrUtils.java
private static LocalDateTime getLocalDateTimeFromEpochTime(String fieldName, Object coercedValue) { Long date = DataTypeUtils.toLong(coercedValue, fieldName); return Instant.ofEpochMilli(date).atZone(ZoneId.systemDefault()).toLocalDateTime(); }
From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java
@Test public void durationReminderWithAnotherBeforeUserZoneIdOnSeveralDaysEventOf2HoursShouldWork() throws Exception { receiver.getUserPreferences().setZoneId(ZoneId.of("America/Cancun")); final DurationReminder durationReminder = initReminderBuilder( setupSeveralDaysEventOn2Hours(ZoneId.systemDefault())).triggerBefore(0, TimeUnit.MINUTE, ""); triggerDateTime(durationReminder);//from ww w .j a v a 2 s .com final Map<String, String> titles = computeNotificationTitles(durationReminder); assertThat(titles.get(DE), is("Reminder about the event super test - 21.02.2018 23:00 - 22.02.2018 01:00 (UTC)")); assertThat(titles.get(EN), is("Reminder about the event super test - 02/21/2018 23:00 - 02/22/2018 01:00 (UTC)")); assertThat(titles.get(FR), is("Rappel sur l'vnement super test - 21/02/2018 23:00 - 22/02/2018 01:00 (UTC)")); final Map<String, String> contents = computeNotificationContents(durationReminder); assertThat(contents.get(DE), is( "REMINDER: The event <b>super test</b> will be from 21.02.2018 at 23:00 to 22.02.2018 at 01:00 (UTC).")); assertThat(contents.get(EN), is( "REMINDER: The event <b>super test</b> will be from 02/21/2018 at 23:00 to 02/22/2018 at 01:00 (UTC).")); assertThat(contents.get(FR), is( "RAPPEL : L'vnement <b>super test</b> aura lieu du 21/02/2018 23:00 au 22/02/2018 01:00 (UTC).")); }
From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java
@Test public void durationReminderWithAnotherAfterUserZoneIdOnSeveralDaysEventOf2HoursShouldWork() throws Exception { receiver.getUserPreferences().setZoneId(ZoneId.of("Asia/Muscat")); final DurationReminder durationReminder = initReminderBuilder( setupSeveralDaysEventOn2Hours(ZoneId.systemDefault())).triggerBefore(0, TimeUnit.MINUTE, ""); triggerDateTime(durationReminder);//from w w w.j av a 2s. c o m final Map<String, String> titles = computeNotificationTitles(durationReminder); assertThat(titles.get(DE), is("Reminder about the event super test - 21.02.2018 23:00 - 22.02.2018 01:00 (UTC)")); assertThat(titles.get(EN), is("Reminder about the event super test - 02/21/2018 23:00 - 02/22/2018 01:00 (UTC)")); assertThat(titles.get(FR), is("Rappel sur l'vnement super test - 21/02/2018 23:00 - 22/02/2018 01:00 (UTC)")); final Map<String, String> contents = computeNotificationContents(durationReminder); assertThat(contents.get(DE), is( "REMINDER: The event <b>super test</b> will be from 21.02.2018 at 23:00 to 22.02.2018 at 01:00 (UTC).")); assertThat(contents.get(EN), is( "REMINDER: The event <b>super test</b> will be from 02/21/2018 at 23:00 to 02/22/2018 at 01:00 (UTC).")); assertThat(contents.get(FR), is( "RAPPEL : L'vnement <b>super test</b> aura lieu du 21/02/2018 23:00 au 22/02/2018 01:00 (UTC).")); }
From source file:edu.usu.sdl.openstorefront.service.UserServiceImpl.java
@Override public void cleanupOldUserMessages() { int maxDays = Convert.toInteger(PropertiesManager.getValue(PropertiesManager.KEY_MESSAGE_KEEP_DAYS, "30")); LocalDateTime archiveTime = LocalDateTime.now(); archiveTime = archiveTime.minusDays(maxDays); archiveTime = archiveTime.truncatedTo(ChronoUnit.DAYS); String deleteQuery = "updateDts < :maxUpdateDts AND activeStatus = :activeStatusParam"; ZonedDateTime zdt = archiveTime.atZone(ZoneId.systemDefault()); Date archiveDts = Date.from(zdt.toInstant()); Map<String, Object> queryParams = new HashMap<>(); queryParams.put("maxUpdateDts", archiveDts); queryParams.put("activeStatusParam", UserMessage.INACTIVE_STATUS); persistenceService.deleteByQuery(UserMessage.class, deleteQuery, queryParams); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testUpdateEventHeader() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);//ww w . ja v a 2s . co m Event event = pair.getLeft(); String username = pair.getRight(); Map<String, String> desc = new HashMap<>(); desc.put("en", "muh description new"); desc.put("it", "muh description new"); desc.put("de", "muh description new"); EventModification em = new EventModification(event.getId(), Event.EventType.INTERNAL, "http://example.com/new", null, "http://example.com/tc", "https://example.com/img.png", null, event.getShortName(), "new display name", event.getOrganizationId(), event.getLocation(), "0.0", "0.0", ZoneId.systemDefault().getId(), desc, DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd().plusDays(42)), event.getRegularPrice(), event.getCurrency(), eventRepository.countExistingTickets(event.getId()), event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), Collections.emptyList(), false, null, 7, null, null); eventManager.updateEventHeader(event, em, username); Event updatedEvent = eventRepository.findById(event.getId()); Assert.assertEquals("http://example.com/new", updatedEvent.getWebsiteUrl()); Assert.assertEquals("http://example.com/tc", updatedEvent.getTermsAndConditionsUrl()); Assert.assertEquals("https://example.com/img.png", updatedEvent.getImageUrl()); Assert.assertEquals("new display name", updatedEvent.getDisplayName()); }
From source file:org.apache.james.queue.jms.JMSMailQueue.java
@Override @SuppressWarnings("unchecked") public MailQueueIterator browse() throws MailQueueException { QueueBrowser browser = null;/*from w ww . j ava2s . c o m*/ try { browser = session.createBrowser(queue); Enumeration<Message> messages = browser.getEnumeration(); QueueBrowser myBrowser = browser; return new MailQueueIterator() { @Override public void remove() { throw new UnsupportedOperationException("Read-only"); } @Override public MailQueueItemView next() { while (hasNext()) { try { Message m = messages.nextElement(); return new MailQueueItemView(createMail(m), nextDeliveryDate(m)); } catch (MessagingException | JMSException e) { LOGGER.error("Unable to browse queue", e); } } throw new NoSuchElementException(); } private ZonedDateTime nextDeliveryDate(Message m) throws JMSException { long nextDeliveryTimestamp = m.getLongProperty(JAMES_NEXT_DELIVERY); return Instant.ofEpochMilli(nextDeliveryTimestamp).atZone(ZoneId.systemDefault()); } @Override public boolean hasNext() { return messages.hasMoreElements(); } @Override public void close() { closeBrowser(myBrowser); } }; } catch (Exception e) { closeBrowser(browser); LOGGER.error("Unable to browse queue {}", queueName, e); throw new MailQueueException("Unable to browse queue " + queueName, e); } }