/** * Parse from a string to produce a duration. * * @return A Duration parsed from the string. * @throws ParseException if parsing fails. * @deprecated Use {@link Durations#parse} instead. */ @Deprecated public static Duration parseDuration(String value) throws ParseException { return Durations.parse(value); }
private void mergeDuration(JsonElement json, Message.Builder builder) throws InvalidProtocolBufferException { try { Duration value = Durations.parse(json.getAsString()); builder.mergeFrom(value.toByteString()); } catch (ParseException e) { throw new InvalidProtocolBufferException("Failed to parse duration: " + json); } }
private void mergeDuration(JsonElement json, Message.Builder builder) throws InvalidProtocolBufferException { try { Duration value = Durations.parse(json.getAsString()); builder.mergeFrom(value.toByteString()); } catch (ParseException e) { throw new InvalidProtocolBufferException("Failed to parse duration: " + json); } }
private void mergeDuration(JsonElement json, Message.Builder builder) throws InvalidProtocolBufferException { try { Duration value = Durations.parse(json.getAsString()); builder.mergeFrom(value.toByteString()); } catch (ParseException e) { throw new InvalidProtocolBufferException("Failed to parse duration: " + json); } }
private void mergeDuration(JsonElement json, Message.Builder builder) throws InvalidProtocolBufferException { try { Duration value = Durations.parse(json.getAsString()); builder.mergeFrom(value.toByteString()); } catch (ParseException e) { throw new InvalidProtocolBufferException("Failed to parse duration: " + json); } }
@Override public Duration deserialize(JsonParser parser, DeserializationContext context) throws IOException { switch (parser.getCurrentToken()) { case VALUE_STRING: try { return Durations.parse(parser.getText()); } catch (ParseException e) { throw context.weirdStringException(parser.getText(), Duration.class, e.getMessage()); } default: throw context.wrongTokenException(parser, JsonToken.VALUE_STRING, wrongTokenMessage(context)); } }