List of usage examples for java.time ZonedDateTime parse
public static ZonedDateTime parse(CharSequence text)
From source file:org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper.java
/** * This is a convenience method that will get the values from a SlotType1 * * @param slot the SlotType1 to get the values from, null returns empty List * @return a List of Date values found in the SlotType1 */// ww w . j a v a2 s .c om public List<Date> getDateValues(SlotType1 slot) { return getStringValues(slot).stream() .map(dateString -> Date.from(ZonedDateTime.parse(dateString).toInstant())) .collect(Collectors.toList()); }
From source file:org.apache.james.jmap.methods.integration.cucumber.GetMessagesMethodStepdefs.java
private void appendMessage(String mailbox, ContentType contentType, String subject, String content, Optional<Map<String, String>> headers) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser, new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox), new ByteArrayInputStream(message(contentType, subject, content, headers).getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); }
From source file:alfio.manager.system.DataMigrator.java
@Autowired public DataMigrator(EventMigrationRepository eventMigrationRepository, EventRepository eventRepository, TicketCategoryRepository ticketCategoryRepository, @Value("${alfio.version}") String currentVersion, @Value("${alfio.build-ts}") String buildTimestamp, PlatformTransactionManager transactionManager, ConfigurationRepository configurationRepository, NamedParameterJdbcTemplate jdbc) { this.eventMigrationRepository = eventMigrationRepository; this.eventRepository = eventRepository; this.ticketCategoryRepository = ticketCategoryRepository; this.configurationRepository = configurationRepository; this.jdbc = jdbc; this.currentVersion = parseVersion(currentVersion); this.currentVersionAsString = currentVersion; this.buildTimestamp = ZonedDateTime.parse(buildTimestamp); this.transactionTemplate = new TransactionTemplate(transactionManager, new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW)); }
From source file:org.apache.james.jmap.methods.integration.GetVacationResponseTest.java
@Test public void getVacationResponseShouldReturnStoredValue() { jmapGuiceProbe.modifyVacation(AccountId.fromString(USER), VacationPatch.builder().isEnabled(true).fromDate(ZonedDateTime.parse("2014-09-30T14:10:00Z")) .toDate(ZonedDateTime.parse("2014-10-30T14:10:00Z")) .textBody("Test explaining my vacations").subject(SUBJECT) .htmlBody("<p>Test explaining my vacations</p>").build()); given().header("Authorization", accessToken.serialize()) .body("[[" + "\"getVacationResponse\", " + "{}, " + "\"#0\"" + "]]").when().post("/jmap").then() .statusCode(200).body(NAME, equalTo("vacationResponse")) .body(ARGUMENTS + ".accountId", equalTo(USER)).body(ARGUMENTS + ".list", hasSize(1)) .body(ARGUMENTS + ".list[0].id", equalTo("singleton")) .body(ARGUMENTS + ".list[0].fromDate", equalTo("2014-09-30T14:10:00Z")) .body(ARGUMENTS + ".list[0].toDate", equalTo("2014-10-30T14:10:00Z")) .body(ARGUMENTS + ".list[0].isEnabled", equalTo(true)) .body(ARGUMENTS + ".list[0].textBody", equalTo("Test explaining my vacations")) .body(ARGUMENTS + ".list[0].subject", equalTo(SUBJECT)) .body(ARGUMENTS + ".list[0].htmlBody", equalTo("<p>Test explaining my vacations</p>")); }
From source file:org.apache.james.jmap.methods.integration.cucumber.GetMessagesMethodStepdefs.java
private void appendMessage(String emlFileName) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser, new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, "inbox"), ClassLoader.getSystemResourceAsStream(emlFileName), Date.from(dateTime.toInstant()), false, new Flags()); }
From source file:sx.blah.discord.api.internal.DiscordUtils.java
/** * Converts a String timestamp into a {@link Instant}. * * @param time The string timestamp.// w w w. j a va2 s . co m * @return The LocalDateTime representing the timestamp. */ public static Instant convertFromTimestamp(String time) { return time == null ? Instant.now() : ZonedDateTime.parse(time).toInstant(); }
From source file:org.codice.ddf.registry.schemabindings.RegistryPackageUtils.java
public static List<Date> getSlotDateValues(SlotType1 slot) { List<Date> dates = new ArrayList<>(); if (slot.isSetValueList()) { ValueListType valueList = slot.getValueList().getValue(); if (valueList.isSetValue()) { List<String> values = valueList.getValue(); for (String dateString : values) { Date date = Date.from(ZonedDateTime.parse(dateString).toInstant()); if (date != null) { dates.add(date);/*w w w . jav a 2 s. c om*/ } } } } return dates; }
From source file:org.apache.james.jmap.methods.integration.GetVacationResponseTest.java
@Test public void getVacationResponseShouldReturnStoredValueWithNonDefaultTimezone() { jmapGuiceProbe.modifyVacation(AccountId.fromString(USER), VacationPatch.builder().isEnabled(true).fromDate(ZonedDateTime.parse("2014-09-30T14:10:00+02:00")) .toDate(ZonedDateTime.parse("2016-04-15T11:56:32.224+07:00[Asia/Vientiane]")) .textBody("Test explaining my vacations").build()); given().header("Authorization", accessToken.serialize()) .body("[[" + "\"getVacationResponse\", " + "{}, " + "\"#0\"" + "]]").when().post("/jmap").then() .statusCode(200).body(NAME, equalTo("vacationResponse")) .body(ARGUMENTS + ".accountId", equalTo(USER)).body(ARGUMENTS + ".list", hasSize(1)) .body(ARGUMENTS + ".list[0].id", equalTo("singleton")) .body(ARGUMENTS + ".list[0].fromDate", equalTo("2014-09-30T14:10:00+02:00")) .body(ARGUMENTS + ".list[0].toDate", equalTo("2016-04-15T11:56:32.224+07:00[Asia/Vientiane]")) .body(ARGUMENTS + ".list[0].isEnabled", equalTo(true)) .body(ARGUMENTS + ".list[0].textBody", equalTo("Test explaining my vacations")); }
From source file:org.apache.james.jmap.methods.integration.SetVacationResponseTest.java
@Test public void setVacationResponseShouldReturnCorrectAnswerUponValidVacationResponse() { String bodyRequest = "[[" + "\"setVacationResponse\", " + "{" + "\"update\":{" + "\"singleton\" : {" + "\"id\": \"singleton\"," + "\"isEnabled\": \"true\"," + "\"textBody\": \"Message explaining my wonderful vacations\"," + "\"htmlBody\": \"<p>Here is the HTML version</p>\"," + "\"fromDate\":\"2014-09-30T14:10:00Z[GMT]\"," + "\"toDate\":\"2014-10-30T14:10:00Z[GMT]\"," + "\"subject\":\"" + SUBJECT + "\"" + "}" + "}" + "}, " + "\"#0\"" + "]]"; given().header("Authorization", accessToken.serialize()).body(bodyRequest).when().post("/jmap").then() .statusCode(200).body(NAME, equalTo("vacationResponseSet")) .body(ARGUMENTS + ".updated[0]", equalTo("singleton")); Vacation vacation = jmapGuiceProbe.retrieveVacation(AccountId.fromString(USER)); assertThat(vacation.getTextBody()).contains("Message explaining my wonderful vacations"); assertThat(vacation.getHtmlBody()).contains("<p>Here is the HTML version</p>"); assertThat(vacation.isEnabled()).isTrue(); assertThat(vacation.getFromDate()).contains(ZonedDateTime.parse("2014-09-30T14:10:00Z[GMT]")); assertThat(vacation.getToDate()).contains(ZonedDateTime.parse("2014-10-30T14:10:00Z[GMT]")); assertThat(vacation.getSubject()).contains(SUBJECT); }
From source file:org.lightjason.agentspeak.action.builtin.TestCActionDateTime.java
/** * generate test-case of apply definition * * @param p_action used-action//from ww w .j a v a 2 s . c om * @param p_datetime referenced date-time * @param p_value value of the action arguments * @param p_result result time string * @return test object */ private static Object testcaseapply(final IAction p_action, final String p_datetime, final int p_value, final String p_result) { return new ImmutableTriple<>(p_action, new ImmutablePair<>(ZonedDateTime.parse(p_datetime), p_value), p_result); }