Package org.joda.time

Examples of org.joda.time.ReadablePeriod


  }

  public void testDeserializeMinutes() throws Exception
  {
    ObjectMapper objectMapper = jodaMapper();
    ReadablePeriod readablePeriod = objectMapper.readValue( "{\"fieldType\":{\"name\":\"minutes\"},\"minutes\":1,\"periodType\":{\"name\":\"Minutes\"}}", ReadablePeriod.class );
    assertNotNull( readablePeriod );
    assertEquals( Minutes.minutes( 1 ), readablePeriod );
  }
View Full Code Here


  }

  public void testDeserializeHours() throws Exception
  {
    ObjectMapper objectMapper = jodaMapper();
    ReadablePeriod readablePeriod = objectMapper.readValue( "{\"fieldType\":{\"name\":\"hours\"},\"hours\":2,\"periodType\":{\"name\":\"Hours\"}}", ReadablePeriod.class );
    assertNotNull( readablePeriod );
    assertEquals( Hours.hours( 2 ), readablePeriod );
  }
View Full Code Here

  }

  public void testDeserializeDays() throws Exception
  {
    ObjectMapper objectMapper = jodaMapper();
    ReadablePeriod readablePeriod = objectMapper.readValue( "{\"fieldType\":{\"name\":\"days\"},\"days\":2,\"periodType\":{\"name\":\"Days\"}}", ReadablePeriod.class );
    assertNotNull( readablePeriod );
    assertEquals( Days.days( 2 ), readablePeriod );
  }
View Full Code Here

  }
 
  public void testDeserializeWeeks() throws Exception
  {
    ObjectMapper objectMapper = jodaMapper();
    ReadablePeriod readablePeriod = objectMapper.readValue( "{\"fieldType\":{\"name\":\"weeks\"},\"weeks\":2,\"periodType\":{\"name\":\"Weeks\"}}", ReadablePeriod.class );
    assertNotNull( readablePeriod );
    assertEquals( Weeks.weeks( 2 ), readablePeriod );
  }
View Full Code Here

  }
 
  public void testDeserializeMonths() throws Exception
  {
    ObjectMapper objectMapper = jodaMapper();
    ReadablePeriod readablePeriod = objectMapper.readValue( "{\"fieldType\":{\"name\":\"months\"},\"months\":2,\"periodType\":{\"name\":\"Months\"}}", ReadablePeriod.class );
    assertNotNull( readablePeriod );
    assertEquals( Months.months( 2 ), readablePeriod );
  }
View Full Code Here

  }

  public void testDeserializeYears() throws Exception
  {
    ObjectMapper objectMapper = jodaMapper();
    ReadablePeriod readablePeriod = objectMapper.readValue( "{\"fieldType\":{\"name\":\"years\"},\"years\":2,\"periodType\":{\"name\":\"Years\"}}", ReadablePeriod.class );
    assertNotNull( readablePeriod );
    assertEquals( Years.years( 2 ), readablePeriod );
  }
View Full Code Here

    if (format == null) {
      format = new PeriodFormatterBuilder().printZeroRarelyLast().appendDays().appendSuffix("d").appendHours().appendSuffix("h")
          .appendMinutes().appendSuffix("m").appendSecondsWithOptionalMillis().appendSuffix("s").toFormatter();
    }

    ReadablePeriod p = null;

    if (value instanceof ReadableInterval) {
      p = ((ReadableInterval) value).toPeriod();
    } else if (value instanceof ReadableDuration) {
      p = ((ReadableDuration) value).toPeriod();
View Full Code Here

            return true;
        }
        if (period instanceof ReadablePeriod == false) {
            return false;
        }
        ReadablePeriod other = (ReadablePeriod) period;
        if (size() != other.size()) {
            return false;
        }
        for (int i = 0, isize = size(); i < isize; i++) {
            if (getValue(i) != other.getValue(i) || getFieldType(i) != other.getFieldType(i)) {
                return false;
            }
        }
        return true;
    }
View Full Code Here

            return true;
        }
        if (period instanceof ReadablePeriod == false) {
            return false;
        }
        ReadablePeriod other = (ReadablePeriod) period;
        return (other.getPeriodType() == getPeriodType() && other.getValue(0) == getValue());
    }
View Full Code Here

     * @return the period type from the readable duration
     * @throws NullPointerException if the object is null
     * @throws ClassCastException if the object is an invalid type
     */
    public PeriodType getPeriodType(Object object) {
        ReadablePeriod period = (ReadablePeriod) object;
        return period.getPeriodType();
    }
View Full Code Here

TOP

Related Classes of org.joda.time.ReadablePeriod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.