public static String getValueLabel ( final Object value ) { if ( value == null ) { return NULL_LABEL ; } if ( value instanceof HasLabelAdvice ) { final String suggestedLabel = ( ( HasLabelAdvice ) value ) . getSuggestedLabel ( ) ; if ( ! Strings . isNullOrEmpty ( suggestedLabel ) ) { return suggestedLabel ; } } // format decimals if ( value instanceof Double || value instanceof Float || value instanceof BigDecimal ) { final NumberFormat format = NumberFormat . getNumberInstance ( ) ; final String result = format . format ( ( Number ) value ) ; logger . debug ( "Formatted decimal {} to: {}" , value , result ) ; return result ; } // format dates if ( value instanceof Date ) { final SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd hh:mm:ss" ) ; final String result = format . format ( ( Date ) value ) ; logger . debug ( "Formatted date {} to: {}" , value , result ) ; return result ; } return getLabel ( value . toString ( ) ) ; }
Gets the label of a value eg . a value in a crosstab .