Java Code Examples for java.time.ZonedDateTime#from()

The following examples show how to use java.time.ZonedDateTime#from() . 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: DatabaseRecord.java    From PlayTimeTracker with MIT License 6 votes vote down vote up
@Override
public DatabaseRecord clone() {
    try {
        DatabaseRecord r = (DatabaseRecord) super.clone();
        r.completedLifetimeMissions = new HashSet<>(completedLifetimeMissions);
        r.completedDailyMissions = new HashSet<>(completedDailyMissions);
        r.completedMonthlyMissions = new HashSet<>(completedMonthlyMissions);
        r.completedWeeklyMissions = new HashSet<>(completedWeeklyMissions);
        r.lastSeen = ZonedDateTime.from(lastSeen);
        return r;
    } catch (CloneNotSupportedException ex) {
        ex.printStackTrace();
        Main.log("Failed to clone: " + toString());
    }
    return new DatabaseRecord();
}
 
Example 2
Source File: TCKZonedDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 3
Source File: TCKZonedDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 4
Source File: TestDateTimeParsing.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "instantNoZone", expectedExceptions = DateTimeException.class)
public void test_parse_instantNoZone_ZDT(DateTimeFormatter formatter, String text, Instant expected) {
    TemporalAccessor actual = formatter.parse(text);
    ZonedDateTime.from(actual);
}
 
Example 5
Source File: TCKZonedDateTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 6
Source File: TCKZonedDateTime.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 7
Source File: Java8TimeGsonAdaptable.java    From lastaflute with Apache License 2.0 4 votes vote down vote up
@Override
protected ZonedDateTime fromTemporal(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 8
Source File: AdvancedModifiableKeyStoreDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    ModifiableKeyStoreService keyStoreService = getModifiableKeyStoreService(context);
    KeyStore keyStore = keyStoreService.getModifiableValue();

    String alias = ALIAS.resolveModelAttribute(context, operation).asString();
    String algorithm = ALGORITHM.resolveModelAttribute(context, operation).asStringOrNull();
    String signatureAlgorithm = SIGNATURE_ALGORITHM.resolveModelAttribute(context, operation).asStringOrNull();
    Integer keySize = KEY_SIZE.resolveModelAttribute(context, operation).asIntOrNull();
    String distinguishedName = DISTINGUISHED_NAME.resolveModelAttribute(context, operation).asString();
    String notBefore = NOT_BEFORE.resolveModelAttribute(context, operation).asStringOrNull();
    Long validity = VALIDITY.resolveModelAttribute(context, operation).asLong();
    ModelNode extensions = EXTENSIONS.resolveModelAttribute(context, operation);
    ExceptionSupplier<CredentialSource, Exception> credentialSourceSupplier = null;
    ModelNode credentialReference = CREDENTIAL_REFERENCE.resolveModelAttribute(context, operation);
    if (credentialReference.isDefined()) {
        credentialSourceSupplier = CredentialReference.getCredentialSourceSupplier(context, CREDENTIAL_REFERENCE, operation, null);
    }
    char[] keyPassword = resolveKeyPassword(((KeyStoreService) keyStoreService), credentialSourceSupplier);

    try {
        if (keyStore.containsAlias(alias)) {
            throw ROOT_LOGGER.keyStoreAliasAlreadyExists(alias);
        }
        SelfSignedX509CertificateAndSigningKey.Builder certAndKeyBuilder = SelfSignedX509CertificateAndSigningKey.builder();
        certAndKeyBuilder.setDn(new X500Principal(distinguishedName));
        if (algorithm != null) {
            certAndKeyBuilder.setKeyAlgorithmName(algorithm);
        }
        if (signatureAlgorithm != null) {
            certAndKeyBuilder.setSignatureAlgorithmName(signatureAlgorithm);
        }
        if (keySize != null) {
            certAndKeyBuilder.setKeySize(keySize);
        }
        final ZonedDateTime notBeforeDateTime;
        if (notBefore != null) {
            notBeforeDateTime = ZonedDateTime.from(NOT_VALID_BEFORE_FORMATTER.parse(notBefore));
        } else {
            notBeforeDateTime = ZonedDateTime.now();
        }
        certAndKeyBuilder.setNotValidBefore(notBeforeDateTime);
        certAndKeyBuilder.setNotValidAfter(notBeforeDateTime.plusDays(validity));
        if (extensions.isDefined()) {
            for (ModelNode extension : extensions.asList()) {
                Boolean critical = CRITICAL.resolveModelAttribute(context, extension).asBoolean();
                String extensionName = NAME.resolveModelAttribute(context, extension).asString();
                String extensionValue = VALUE.resolveModelAttribute(context, extension).asString();
                certAndKeyBuilder.addExtension(critical, extensionName, extensionValue);
            }
        }

        SelfSignedX509CertificateAndSigningKey certAndKey = certAndKeyBuilder.build();
        final PrivateKey privateKey = certAndKey.getSigningKey();
        final X509Certificate[] certChain = new X509Certificate[1];
        certChain[0] = certAndKey.getSelfSignedCertificate();
        keyStore.setKeyEntry(alias, privateKey, keyPassword, certChain);
    } catch (Exception e) {
        rollbackCredentialStoreUpdate(CREDENTIAL_REFERENCE, context, credentialReference);
        if (e instanceof IllegalArgumentException) {
            throw new OperationFailedException(e);
        } else {
            throw new RuntimeException(e);
        }
    }
}
 
Example 9
Source File: TCKZonedDateTime.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
    ZonedDateTime.from((TemporalAccessor) null);
}
 
Example 10
Source File: TCKZonedDateTime.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 11
Source File: TCKZonedDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 12
Source File: TCKZonedDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
    ZonedDateTime.from(LocalTime.of(12, 30));
}
 
Example 13
Source File: IsoChronology.java    From j2objc with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 14
Source File: IsoChronology.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 15
Source File: IsoChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 16
Source File: IsoChronology.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 17
Source File: IsoChronology.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 18
Source File: IsoChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 19
Source File: IsoChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}
 
Example 20
Source File: IsoChronology.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains an ISO zoned date-time from another date-time object.
 * <p>
 * This is equivalent to {@link ZonedDateTime#from(TemporalAccessor)}.
 *
 * @param temporal  the date-time object to convert, not null
 * @return the ISO zoned date-time, not null
 * @throws DateTimeException if unable to create the date-time
 */
@Override  // override with covariant return type
public ZonedDateTime zonedDateTime(TemporalAccessor temporal) {
    return ZonedDateTime.from(temporal);
}