Example usage for org.joda.time.format DateTimeParserBucket setZone

List of usage examples for org.joda.time.format DateTimeParserBucket setZone

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeParserBucket setZone.

Prototype

public void setZone(DateTimeZone zone) 

Source Link

Document

Set a time zone to be used when computeMillis is called.

Usage

From source file:org.jpmml.evaluator.TypeUtil.java

License:Open Source License

@SuppressWarnings(value = { "deprecation" })
static private Seconds parseSeconds(String value) {
    DateTimeFormatter format = SecondsSinceMidnight.getFormat();

    DateTimeParser parser = format.getParser();

    DateTimeParserBucket bucket = new DateTimeParserBucket(0, null, null);
    bucket.setZone(null);

    int result = parser.parseInto(bucket, value, 0);
    if (result >= 0 && result >= value.length()) {
        long millis = bucket.computeMillis(true);

        return Seconds.seconds((int) (millis / 1000L));
    }/*from   ww w  .  j  a  v a  2 s. co  m*/

    throw new IllegalArgumentException(value);
}

From source file:org.whole.lang.xsd.parsers.AbstractISO8601DataTypeParser.java

License:Open Source License

public Object parseObject(EntityDescriptor<?> ed, String value) {
    DateTimeParser parser = getFormatter().getParser();
    DateTimeParserBucket bucket = new DateTimeParserBucket(0, ISOChronology.getInstance(), null);

    // use a custom UTC to check if offset part is parsed
    if (bucket.getZone() == null)
        bucket.setZone(UTC);

    if (parser.parseInto(bucket, value, 0) < 0)
        throw new WholeIllegalArgumentException(WholeMessages.no_data_type);

    DateTimeZone zone = bucket.getZone();
    if (zone == null)
        return parseWithTimeZone(bucket);
    else//from   w  w  w. j a  v  a 2s .c  o  m
        return parseWithoutTimeZone(bucket);
}