Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.revolsys.ui.html.serializer.key;
 
Serialize a date with the date and time fields.

Author(s):
Paul Austin
public class DateTimeKeySerializer extends DateKeySerializer {
  
The date format style.
  private int timeStyle = .;

  
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.getDateTimeInstance(getDateStyle(), getTimeStyle(),
      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 setTimeStyle(final String styleName) {
    try {
      Field styleField = DateFormat.class.getField(styleName.toUpperCase());
      setTimeStyle(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 time style.

Returns:
The time style.
  public int getTimeStyle() {
    return ;
  }

  
Set the time style.

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