public String interval ( Date target ) { double unit = 1000.0D ; double dayUnit = DAY / unit ; double hourUnit = HOUR / unit ; double minUnit = MINUTE / unit ; double interval = sinceMillis ( target ) / unit ; IntervalDesc desc = theIntervalDesc . get ( ) ; if ( interval >= 0.0D ) { if ( interval / ( 12 * 30 * dayUnit ) > 1.0D ) { return asText ( target ) ; } if ( interval / ( 30 * dayUnit ) > 1.0D ) { return String . format ( "%s%s" , ( int ) ( interval / ( 30 * dayUnit ) ) , desc . getMonthAgo ( ) ) ; } if ( interval / ( 7 * dayUnit ) > 1.0D ) { return String . format ( "7%s" , desc . getDayAgo ( ) ) ; } if ( ( interval / ( 7 * dayUnit ) <= 1.0D ) && ( interval / dayUnit >= 1.0D ) ) { return String . format ( "%s%s" , ( int ) ( interval / dayUnit ) , desc . getDayAgo ( ) ) ; } if ( ( interval / dayUnit < 1.0D ) && ( interval / hourUnit >= 1.0D ) ) { return String . format ( "%s%s" , ( int ) ( interval / hourUnit ) , desc . getHourAgo ( ) ) ; } if ( ( interval < hourUnit ) && ( interval >= minUnit ) ) { return String . format ( "%s%s" , ( int ) ( interval / minUnit ) , desc . getMinuteAgo ( ) ) ; } return desc . getJustNow ( ) ; } return asText ( target ) ; }
Returns the interval describe since given date to the delegate date