static org . joda . time . Period convertToPeriod ( int value , String udunit ) { if ( udunit . endsWith ( "s" ) ) udunit = udunit . substring ( 0 , udunit . length ( ) - 1 ) ; switch ( udunit ) { case "msec" : return Period . millis ( value ) ; case "sec" : return Period . seconds ( value ) ; case "minute" : return Period . minutes ( value ) ; case "hour" : case "hr" : return Period . hours ( value ) ; case "day" : return Period . days ( value ) ; case "week" : return Period . weeks ( value ) ; case "month" : return Period . months ( value ) ; case "year" : return Period . years ( value ) ; } throw new IllegalArgumentException ( "cant convert " + udunit + " to Joda Period" ) ; }
Convert a time udunit string