Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.revolsys.ui.html.serializer.type;
 
 
Serialize a date with just the date fields.

Author(s):
Paul Austin
public class BooleanSerializer implements TypeSerializer {
  
The date format style.
  private int dateStyle = .;

  
Serialize the value to the XML writer using the settings from the Locale.

Parameters:
out The XML writer to serialize to.
value The object to get the value from.
locale The locale.
  public void serialize(
    final XmlWriter out,
    final Object value,
    final Locale locale) {
    if (value instanceof Boolean) {
      Boolean bool = (Boolean)value;
      if (bool.booleanValue()) {
        out.text("Yes");
      } else {
        out.text("No");
      }
    } else {
      out.text("No");
    }
  }

  
Get the date format instance for the locale.

Parameters:
locale The locale.
Returns:
The date format instance.
  protected DateFormat getDateFormat(
    final Locale locale) {
    return SimpleDateFormat.getDateInstance(locale);
  }

  
Set the name of the style for use by java.text.DateFormat.getDateInstance(int,java.util.Locale).

Parameters:
styleName The name of the date format style;
  public void setDateStyle(
    final String styleName) {
    try {
      Field styleField = DateFormat.class.getField(styleName.toUpperCase());
      setDateStyle(styleField.getInt(DateFormat.class));
    } catch (SecurityException e) {
      throw new RuntimeException(e.getMessage(), e);
    } catch (NoSuchFieldException e) {
      throw new IllegalArgumentException(styleName
        + " is not a valid DateFormat style");
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }

  
Get the dete style.

Returns:
The date style.
  public int getDateStyle() {
    return ;
  }

  
Set the dete style.

Parameters:
dateStyle The date style.
  public void setDateStyle(
    final int dateStyle) {
    this. = dateStyle;
  }
New to GrepCode? Check out our FAQ X