Java Date Format Pattern getFormattedValue(Object customFieldValue)

Here you can find the source of getFormattedValue(Object customFieldValue)

Description

Get a formatted value as pattern "dd/MMM/yy" if the value is instance of Date

License

BSD License

Parameter

Parameter Description
customFieldValue to format

Return

formatted value

Declaration

public static String getFormattedValue(Object customFieldValue) 

Method Source Code


//package com.java2s;
//License from project: BSD License 

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**//ww w  . j a v a 2 s.  c  o  m
     * Get a formatted value as pattern "dd/MMM/yy"
     * if the value is instance of Date
     * @param customFieldValue to format
     * @return formatted value
     */
    public static String getFormattedValue(Object customFieldValue) {
        String cfValue = "";
        if (customFieldValue instanceof Date) {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yy");
            Date date = (Date) customFieldValue;
            cfValue = sdf.format(date).toString();
        } else {
            cfValue = customFieldValue.toString();
        }
        return cfValue;
    }
}

Related

  1. getFormat(String format)
  2. getFormat(String formatPattern)
  3. getFormat(String formatString)
  4. getFormat(String pattern)
  5. getFormatCurrentAdd(int amount, String format)
  6. getFormatter()
  7. getFormatter()
  8. getFormatter(final String pattern)
  9. getFormatter(String pattern)