public static String toDuration ( long inputTime ) { final long second = 1000000000L ; final long minute = 60 * second ; final long hour = 60 * minute ; final long day = 24 * hour ; final long week = 7 * day ; long time = inputTime ; final StringBuilder buf = new StringBuilder ( ) ; buf . append ( ' ' ) ; time = append ( buf , ' ' , week , time ) ; time = append ( buf , ' ' , day , time ) ; buf . append ( ' ' ) ; time = append ( buf , ' ' , hour , time ) ; time = append ( buf , ' ' , minute , time ) ; append ( buf , ' ' , second , time ) ; return buf . toString ( ) ; }
Convert time in nanoseconds to a duration string . This is used to provide a more human readable order of magnitude for the duration . We assume standard fixed size quantities for all units .