public String format ( Direction direction , AbsoluteUnit unit ) { if ( unit == AbsoluteUnit . NOW && direction != Direction . PLAIN ) { throw new IllegalArgumentException ( "NOW can only accept direction PLAIN." ) ; } String result ; // Get plain day of week names from DateFormatSymbols. if ( ( direction == Direction . PLAIN ) && ( AbsoluteUnit . SUNDAY . ordinal ( ) <= unit . ordinal ( ) && unit . ordinal ( ) <= AbsoluteUnit . SATURDAY . ordinal ( ) ) ) { // Convert from AbsoluteUnit days to Calendar class indexing. int dateSymbolsDayOrdinal = ( unit . ordinal ( ) - AbsoluteUnit . SUNDAY . ordinal ( ) ) + Calendar . SUNDAY ; String [ ] dayNames = dateFormatSymbols . getWeekdays ( DateFormatSymbols . STANDALONE , styleToDateFormatSymbolsWidth [ style . ordinal ( ) ] ) ; result = dayNames [ dateSymbolsDayOrdinal ] ; } else { // Not PLAIN, or not a weekday. result = getAbsoluteUnitString ( style , unit , direction ) ; } return result != null ? adjustForContext ( result ) : null ; }
Formats a relative date without a quantity .