public static CharSequence formatDuration ( Context context , ReadableDuration readableDuration ) { Resources res = context . getResources ( ) ; Duration duration = readableDuration . toDuration ( ) ; final int hours = ( int ) duration . getStandardHours ( ) ; if ( hours != 0 ) { return res . getQuantityString ( R . plurals . joda_time_android_duration_hours , hours , hours ) ; } final int minutes = ( int ) duration . getStandardMinutes ( ) ; if ( minutes != 0 ) { return res . getQuantityString ( R . plurals . joda_time_android_duration_minutes , minutes , minutes ) ; } final int seconds = ( int ) duration . getStandardSeconds ( ) ; return res . getQuantityString ( R . plurals . joda_time_android_duration_seconds , seconds , seconds ) ; }
Return given duration in a human - friendly format . For example 4 minutes or 1 second . Returns only largest meaningful unit of time from seconds up to hours .