Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.revolsys.ui.html.serializer.key;
 import java.util.Date;
Serialize a date with the specified date format

Paul Austin
public class DateFormatKeySerializer implements KeySerializer {

The date format style.
  private String dateFormat = "dd-MMM-yyyy";

Construct a new DateFormatKeySerializer.
  public DateFormatKeySerializer() {

Construct a new DateFormatKeySerializer.

dateFormat The date format pattern.
    final String dateFormat) {
    this. = dateFormat;

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

out The XML writer to serialize to.
object The object to get the value from.
key The key of the property on the object to serialize.
locale The locale.
  public void serialize(
    final XmlWriter out,
    final Object object,
    final String key,
    final Locale locale) {
    Object value = JavaBeanUtil.getProperty(objectkey);
    DateFormat format = new SimpleDateFormat(locale);
    if (value == null) {
    } else if (value instanceof Date) {
    } else {

Get the dete format.

The date format.
  public String getDateFormat() {
    return ;

Set the dete format.

dateFormat The date format.
  public void setDateFormat(
    final String dateFormat) {
    this. = dateFormat;
New to GrepCode? Check out our FAQ X