Example usage for org.apache.commons.lang3.time Period valueOf

List of usage examples for org.apache.commons.lang3.time Period valueOf

Introduction

In this page you can find the example usage for org.apache.commons.lang3.time Period valueOf.

Prototype

public static Period valueOf(TimeUnit u, long c) 

Source Link

Usage

From source file:org.springframework.context.support.ExtendedConversionServiceFactoryBeanTest.java

@Test
public void testString2PeriodConversion() {
    for (TimeUnit unit : TimeUnitUtils.VALUES) {
        Period p = Period.valueOf(unit, 1L + unit.ordinal());
        String s = ExtendedObjectToStringConverter.INSTANCE.convert(p);
        testTwoWayConversion(String.class, s, Period.class, StringToPeriodConverter.INSTANCE);
        testTwoWayConversion(Period.class, p, String.class, ExtendedObjectToStringConverter.INSTANCE);
    }//from   w  ww .  ja v a 2  s . com
}

From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImplTest.java

private Map<String, Serializable> createEntityProperties(final String seed) {
    final int unitIndex = RANDOMIZER.nextInt(units.size());
    final int classIndex = RANDOMIZER.nextInt(classes.size());
    return new TreeMap<String, Serializable>(String.CASE_INSENSITIVE_ORDER) {
        private static final long serialVersionUID = 1L;

        {//w w  w .j  a  v a 2  s.  c  o m
            put("testName", seed);
            put("testHash", Integer.valueOf(seed.hashCode()));
            put("nowTime", Long.valueOf(System.nanoTime()));
            put("nowDate", new Date(System.currentTimeMillis()));
            put("nowCalendar", Calendar.getInstance());
            put("randomValue", Double.valueOf(Math.random()));
            put("enumValue", units.get(unitIndex));
            put("periodValue", Period.valueOf(units.get(unitIndex), Math.abs(RANDOMIZER.nextLong())));
            put("classValue", classes.get(classIndex));
        }
    };
}