1 16 17 package org.apache.taglibs.i18n; 18 19 import java.text.DateFormat ; 20 import java.text.Format ; 21 import java.text.SimpleDateFormat ; 22 import java.util.Date ; 23 24 30 public class FormatDateTag extends FormatDateTagSupport { 31 32 protected static final String _tagname = "i18n:formatDate"; 33 34 private Format format; 35 private String pattern; 36 private int style = DateFormat.SHORT; 37 38 39 public void release() { 42 super.release(); 43 format = null; 44 pattern = null; 45 } 46 47 50 54 public Format getFormat() { 55 if ( format == null ) { 56 String pattern = getPattern(); 57 if ( pattern != null ) { 58 format = getPatternFormat( pattern ); 59 } 60 if ( pattern == null ) { 61 format = getDateFormat(); 62 } 63 } 64 return format; 65 } 66 67 public void setFormat( DateFormat format ) { 68 this.format = format; 69 } 70 71 public String getPattern() { 72 return pattern; 73 } 74 75 public void setPattern( String pattern ) { 76 this.pattern = pattern; 77 } 78 79 public void setStyle( String style ) { 80 this.style = getStyleCode( style ); 81 } 82 83 84 protected DateFormat getPatternFormat( String pattern ) { 87 return new SimpleDateFormat ( pattern, getLocale() ); 90 } 91 92 protected DateFormat getDateFormat() { 93 return DateFormat.getDateInstance( style, getLocale() ); 94 } 95 96 } 97 | Popular Tags |