List of usage examples for java.time ZoneId of
public static ZoneId of(String zoneId)
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildClippingsTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.CLIPPINGS)); root.setIcon(VaadinIcons.NEWSPAPER); root.setWidth("100%"); root.setSpacing(true);/*from w w w. j av a 2s . c om*/ root.setMargin(true); FormLayout formLayoutClippingDetails = new FormLayout(); formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(formLayoutClippingDetails); CheckBox checkBoxReceiveEmails = new CheckBox(); checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user)); checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue())); HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails); layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION)); layoutCheckBoxReceiveEmails.setMargin(false); layoutCheckBoxReceiveEmails.setSpacing(false); HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout(); layoutAddNewClippingTime.setMargin(false); layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME)); layoutAddNewClippingTime.setWidth("100%"); InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField(); LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin")); dateFieldNewClippingTime.setValue(value); dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale()); dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE); dateFieldNewClippingTime.addStyleName("time-only"); Button buttonAddClippingTime = new Button(); buttonAddClippingTime.setIcon(VaadinIcons.PLUS); buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonAddClippingTime.addClickListener(e -> { LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime(); layoutClippingTimes.addComponent(getTimeRow(user, generalTime)); UserUtils.addClippingSendTime(user, generalTime); }); layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime); layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT); layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER); layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5); layoutClippingTimes = new VerticalLayout(); layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true)); layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES)); layoutClippingTimes.setWidth("100%"); layoutClippingTimes.addStyleName("times"); Set<LocalTime> userTimes = user.getClippingTime(); userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t))); formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime, layoutClippingTimes); return root; }
From source file:eu.hansolo.fx.weatherfx.darksky.DarkSky.java
private LocalDateTime epochToLocalDateTime(final long TIMESTAMP) { return LocalDateTime.ofInstant(Instant.ofEpochSecond(TIMESTAMP), ZoneId.of(timeZone.getID())); }
From source file:org.mascherl.example.service.ComposeMailService.java
private static ZonedDateTime convertToZonedDateTimeHibernate(TimestampColumnZonedDateTimeMapper mapper, Timestamp dbTimestamp) {/*from w ww . j av a2 s. co m*/ // only needed when querying with hibernate, in order to fix a time zone conversion bug return mapper.fromNonNullValue(dbTimestamp).withZoneSameLocal(ZoneId.of("Z")) .withZoneSameInstant(ZoneId.systemDefault()); }
From source file:eu.hansolo.fx.weatherfx.darksky.DarkSky.java
private LocalDateTime epochStringToLocalDateTime(final String TIME_STRING) { return LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.parseLong(TIME_STRING)), ZoneId.of(timeZone.getID())); }
From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java
@Test public void durationReminderWithAnotherAfterCalendarZoneIdOnSeveralDaysEventOnAllDayShouldWork() throws Exception { final CalendarEvent calendarEvent = setupSeveralDaysEventOnAllDay(); when(calendarEvent.getCalendar().getZoneId()).thenReturn(ZoneId.of("Asia/Muscat")); final DurationReminder durationReminder = initReminderBuilder(calendarEvent).triggerBefore(0, TimeUnit.MINUTE, ""); triggerDateTime(durationReminder);/*from w w w. j a v 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 - 22.02.2018 (Asia/Muscat)")); assertThat(titles.get(EN), is("Reminder about the event super test - 02/21/2018 - 02/22/2018 (Asia/Muscat)")); assertThat(titles.get(FR), is("Rappel sur l'vnement super test - 21/02/2018 - 22/02/2018 (Asia/Muscat)")); 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 to 22.02.2018 (Asia/Muscat).")); assertThat(contents.get(EN), is("REMINDER: The event <b>super test</b> will be from 02/21/2018 to 02/22/2018 (Asia/Muscat).")); assertThat(contents.get(FR), is( "RAPPEL : L'vnement <b>super test</b> aura lieu du 21/02/2018 au 22/02/2018 (Asia/Muscat).")); }
From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJsonTest.java
@Test public void getUpdatedJsonMessagePartShouldBehaveWellOnEmptyFlags() throws Exception { MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson( new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES); assertThatJson(messageToElasticSearchJson.getUpdatedJsonMessagePart(new Flags(), MOD_SEQ)).isEqualTo( "{\"modSeq\":42,\"isAnswered\":false,\"isDeleted\":false,\"isDraft\":false,\"isFlagged\":false,\"isRecent\":false,\"userFlags\":[],\"isUnread\":true}"); }
From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJsonTest.java
@Test public void getUpdatedJsonMessagePartShouldBehaveWellOnNonEmptyFlags() throws Exception { MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson( new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES); assertThatJson(messageToElasticSearchJson.getUpdatedJsonMessagePart(new FlagsBuilder() .add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("user").build(), MOD_SEQ)).isEqualTo( "{\"modSeq\":42,\"isAnswered\":false,\"isDeleted\":true,\"isDraft\":false,\"isFlagged\":true,\"isRecent\":false,\"userFlags\":[\"user\"],\"isUnread\":true}"); }
From source file:sx.blah.discord.DiscordClient.java
public LocalDateTime convertFromTimestamp(String time) { return LocalDateTime.parse(time.split("\\+")[0]).atZone(ZoneId.of("UTC+00:00")) .withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime(); }
From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJsonTest.java
@Test(expected = NullPointerException.class) public void getUpdatedJsonMessagePartShouldThrowIfFlagsIsNull() throws Exception { MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson( new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES); messageToElasticSearchJson.getUpdatedJsonMessagePart(null, MOD_SEQ); }
From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJsonTest.java
@Test public void spamEmailShouldBeWellConvertedToJsonWithApacheTika() throws IOException { MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson( new TikaTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES); MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID, date, SIZE, BODY_START_OCTET, new SharedByteArrayInputStream( IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/nonTextual.eml"))), new Flags(), propertyBuilder, MAILBOX_ID); spamMail.setUid(UID);/*from ww w . j a v a 2s.c o m*/ spamMail.setModSeq(MOD_SEQ); assertThatJson(messageToElasticSearchJson.convertToJson(spamMail, ImmutableList.of(new MockMailboxSession("username").getUser()))).when(IGNORING_ARRAY_ORDER) .isEqualTo(IOUtils.toString(ClassLoader.getSystemResource("eml/nonTextual.json"), CHARSET)); }