Java 8 DateTimeException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DateTimeException class.

This code example shows how to use the following methods:getClass, getMessage
    protected <T> T _rethrowDateTimeException(DeserializationContext ctxt,
            Class<?> type, DateTimeException e0, String value) throws IOException
    { 
        JsonMappingException e;
        if (e0 instanceof DateTimeParseException) {
            e = ctxt.weirdStringException(value, type, e0.getMessage());
            e.initCause(e0);
        } else { 
            e = JsonMappingException.from(ctxt,
                String.format("Failed to deserialize %s: (%s) %s",
                        type.getName(), e0.getClass().getName(), e0.getMessage()), e0);
        } 
        throw e;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getClass, getMessage
This code example shows how to use the following methods:getClass, getMessage
                parser.getCurrentToken());
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getClass, getMessage
    protected <BOGUS> BOGUS _rethrowDateTimeException(JsonParser p, DeserializationContext context,
            DateTimeException e0, String value) throws JsonMappingException
    { 
        JsonMappingException e;
        if (e0 instanceof DateTimeParseException) {
            e = context.weirdStringException(value, handledType(), e0.getMessage());
            e.initCause(e0);
        } else { 
            e = JsonMappingException.from(p,
                String.format("Failed to deserialize %s: (%s) %s",
                        handledType().getName(), e0.getClass().getName(), e0.getMessage()), e0);
        } 
        throw e;
    } 
 
    /** 
     * Helper method used to peel off spurious wrappings of DateTimeException 
     * 
     * @param e DateTimeException to peel 
     *  
5
CodeRank
This code example shows how to use the following methods:getClass, getMessage
    @Override 
    public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException
    { 
        if (parser.hasToken(JsonToken.VALUE_STRING)) {
            String string = parser.getText().trim();
            if (string.length() == 0) {
                return null; 
            } 
            try { 
                switch (_valueType) {
                case TYPE_PERIOD:
                    return Period.parse(string);
                case TYPE_ZONE_ID:
                    return ZoneId.of(string);
                case TYPE_ZONE_OFFSET:
                    return ZoneOffset.of(string);
                } 
            } catch (DateTimeException e) {
                _rethrowDateTimeException(parser, context, e, string);
            } 
5
CodeRank
This code example shows how to use the following methods:
     */ 
    public void validateModifiedJulianDay(long mjDay, long nanoOfDay) {
        long leapSecs = getLeapSecondAdjustment(mjDay);
        long maxNanos = (SECS_PER_DAY + leapSecs) * NANOS_PER_SECOND;
        if (nanoOfDay < 0 || nanoOfDay >= maxNanos) {
            throw new DateTimeException("Nanosecond-of-day must be between 0 and " + maxNanos + " on date " + mjDay);
        } 
    } 
 
    //----------------------------------------------------------------------- 
    /** 
     * Converts a {@code UtcInstant} to a {@code TaiInstant}. 
     * <p> 
     * This method converts from the UTC to the TAI time-scale using the 
     * leap-second rules of the implementation. 
     * 
     * @param utcInstant  the UTC instant to convert, not null 
     * @return the converted TAI instant, not null 
     * @throws DateTimeException if the valid range is exceeded 
     * @throws ArithmeticException if numeric overflow occurs 
3
CodeRank
This code example shows how to use the following methods:
    /** 
     * Singleton instance for the Coptic chronology. 
     */ 
    public static final CopticChronology INSTANCE = new CopticChronology();
 
    /** 
     * Serialization version. 
     */ 
    private static final long serialVersionUID = 7291205177830286973L;
 
    /** 
     * Private constructor, that is public to satisfy the {@code ServiceLoader}. 
     * @deprecated Use the singleton {@link #INSTANCE} instead. 
     */ 
    @Deprecated 
    public CopticChronology() { 
    } 
 
    /** 
     * Resolve singleton. 
3
CodeRank
This code example shows how to use the following methods:
    /** 
     * Singleton instance for the Ethiopic chronology. 
     */ 
    public static final EthiopicChronology INSTANCE = new EthiopicChronology();
 
    /** 
     * Serialization version. 
     */ 
    private static final long serialVersionUID = 53287687268768L;
 
    /** 
     * Private constructor, that is public to satisfy the {@code ServiceLoader}. 
     * @deprecated Use the singleton {@link #INSTANCE} instead. 
     */ 
    @Deprecated 
    public EthiopicChronology() { 
    } 
 
    /** 
     * Resolve singleton. 
3
CodeRank
This code example shows how to use the following methods:
            case 0: 
                return BC;
            case 1: 
                return AD;
            default: 
                throw new DateTimeException("Invalid era: " + era);
        } 
    } 
 
    //----------------------------------------------------------------------- 
    /** 
     * Gets the numeric era {@code int} value. 
     * <p> 
     * The era BC has the value 0, while the era AD has the value 1. 
     * 
     * @return the era value, from 0 (BC) to 1 (AD) 
     */ 
    @Override 
    public int getValue() { 
        return ordinal();
3
CodeRank
This code example shows how to use the following methods:
            case 0: 
                return BEFORE_AM;
            case 1: 
                return AM;
            default: 
                throw new DateTimeException("Invalid era: " + era);
        } 
    } 
 
    //----------------------------------------------------------------------- 
    /** 
     * Gets the numeric era {@code int} value. 
     * <p> 
     * The era BEFORE_AM has the value 0, while the era AM has the value 1. 
     * 
     * @return the era value, from 0 (BEFORE_AM) to 1 (AM) 
     */ 
    @Override 
    public int getValue() { 
        return ordinal();
3
CodeRank
See Code Examples for Java 8 DateTimeException Methods: