public static String createPeriodString ( final ReadablePeriod period ) { String periodStr = "null" ; if ( period == null ) { return periodStr ; } if ( period . get ( DurationFieldType . years ( ) ) > 0 ) { final int years = period . get ( DurationFieldType . years ( ) ) ; periodStr = years + "y" ; } else if ( period . get ( DurationFieldType . months ( ) ) > 0 ) { final int months = period . get ( DurationFieldType . months ( ) ) ; periodStr = months + "M" ; } else if ( period . get ( DurationFieldType . weeks ( ) ) > 0 ) { final int weeks = period . get ( DurationFieldType . weeks ( ) ) ; periodStr = weeks + "w" ; } else if ( period . get ( DurationFieldType . days ( ) ) > 0 ) { final int days = period . get ( DurationFieldType . days ( ) ) ; periodStr = days + "d" ; } else if ( period . get ( DurationFieldType . hours ( ) ) > 0 ) { final int hours = period . get ( DurationFieldType . hours ( ) ) ; periodStr = hours + "h" ; } else if ( period . get ( DurationFieldType . minutes ( ) ) > 0 ) { final int minutes = period . get ( DurationFieldType . minutes ( ) ) ; periodStr = minutes + "m" ; } else if ( period . get ( DurationFieldType . seconds ( ) ) > 0 ) { final int seconds = period . get ( DurationFieldType . seconds ( ) ) ; periodStr = seconds + "s" ; } return periodStr ; }
Convert ReadablePeriod Object to string