| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.struts2.components.Component
org.apache.struts2.components.ContextBean
org.apache.struts2.components.Date
public class Date
Format Date object in different ways.
The date tag will allow you to format a Date in a quick and easy way. You can specify a custom format (eg. "dd/MM/yyyy hh:mm"), you can generate easy readable notations (like "in 2 hours, 14 minutes"), or you can just fall back on a predefined format with key 'struts.date.format' in your properties file. If that key is not defined, it will finally fall back to the default DateFormat.MEDIUM formatting. Note: If the requested Date object isn't found on the stack, a blank will be returned.
Configurable attributes are :-| i18n key | default | 
| struts.date.format.past | {0} ago | 
| struts.date.format.future | in {0} | 
| struts.date.format.seconds | an instant | 
| struts.date.format.minutes | {0,choice,1#one minute|1<{0} minutes} | 
| struts.date.format.hours | {0,choice,1#one hour|1<{0} hours}{1,choice,0#|1#, one minute|1<, {1} minutes} | 
| struts.date.format.days | {0,choice,1#one day|1<{0} days}{1,choice,0#|1#, one hour|1<, {1} hours} | 
| struts.date.format.years | {0,choice,1#one year|1<{0} years}{1,choice,0#|1#, one day|1<, {1} days} | 
In this case the format attribute will be used.
Condition 3: With nice attribute as false and no format attribute is specified| i18n key | default | 
| struts.date.format | if one is not found DateFormat.MEDIUM format will be used | 
  
  <s:date name="person.birthday" format="dd/MM/yyyy" />
  <s:date name="person.birthday" format="%{getText('some.i18n.key')}" />
  <s:date name="person.birthday" nice="true" />
  <s:date name="person.birthday" />
  
 
 Date
| Field Summary | |
|---|---|
private static String | 
DATETAG_DEFAULT_DAYS
 | 
private static String | 
DATETAG_DEFAULT_FUTURE
 | 
private static String | 
DATETAG_DEFAULT_HOURS
 | 
private static String | 
DATETAG_DEFAULT_MINUTES
 | 
private static String | 
DATETAG_DEFAULT_PAST
 | 
private static String | 
DATETAG_DEFAULT_SECONDS
 | 
private static String | 
DATETAG_DEFAULT_YEARS
 | 
static String | 
DATETAG_PROPERTY
Property name to fall back when no format is specified  | 
static String | 
DATETAG_PROPERTY_DAYS
Property name that defines the days notation (default: {0,choice,1#one day|1<{0} days}{1,choice,0#|1#, one hour|1<, {1} hours})  | 
static String | 
DATETAG_PROPERTY_FUTURE
Property name that defines the future notation (default: in {0})  | 
static String | 
DATETAG_PROPERTY_HOURS
Property name that defines the hours notation (default: {0,choice,1#one hour|1<{0} hours}{1,choice,0#|1#, one minute|1<, {1} minutes})  | 
static String | 
DATETAG_PROPERTY_MINUTES
Property name that defines the minutes notation (default: {0,choice,1#one minute|1<{0} minutes})  | 
static String | 
DATETAG_PROPERTY_PAST
Property name that defines the past notation (default: {0} ago)  | 
static String | 
DATETAG_PROPERTY_SECONDS
Property name that defines the seconds notation (default: in instant)  | 
static String | 
DATETAG_PROPERTY_YEARS
Property name that defines the years notation (default: {0,choice,1#one year|1<{0} years}{1,choice,0#|1#, one day|1<, {1} days})  | 
private  String | 
format
 | 
private static Logger | 
LOG
 | 
private  String | 
name
 | 
private  boolean | 
nice
 | 
| Fields inherited from class org.apache.struts2.components.ContextBean | 
|---|
var | 
| Fields inherited from class org.apache.struts2.components.Component | 
|---|
actionMapper, COMPONENT_STACK, parameters, stack | 
| Constructor Summary | |
|---|---|
Date(ValueStack stack)
 | 
|
| Method Summary | |
|---|---|
 boolean | 
end(Writer writer,
    String body)
Callback for the end tag of this component.  | 
private  TextProvider | 
findProviderInStack()
 | 
 String | 
formatTime(TextProvider tp,
           Date date)
Calculates the difference in time from now to the given date, and outputs it nicely.  | 
 String | 
getFormat()
 | 
 String | 
getName()
 | 
 boolean | 
isNice()
 | 
 void | 
setFormat(String format)
 | 
 void | 
setName(String name)
 | 
 void | 
setNice(boolean nice)
 | 
| Methods inherited from class org.apache.struts2.components.ContextBean | 
|---|
getVar, putInContext, setId, setVar | 
| Methods inherited from class org.apache.struts2.components.Component | 
|---|
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getParameters, getStack, popComponentStack, setActionMapper, start, toString, usesBody | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
private static final Logger LOG
public static final String DATETAG_PROPERTY
public static final String DATETAG_PROPERTY_PAST
private static final String DATETAG_DEFAULT_PAST
public static final String DATETAG_PROPERTY_FUTURE
private static final String DATETAG_DEFAULT_FUTURE
public static final String DATETAG_PROPERTY_SECONDS
private static final String DATETAG_DEFAULT_SECONDS
public static final String DATETAG_PROPERTY_MINUTES
private static final String DATETAG_DEFAULT_MINUTES
public static final String DATETAG_PROPERTY_HOURS
private static final String DATETAG_DEFAULT_HOURS
public static final String DATETAG_PROPERTY_DAYS
private static final String DATETAG_DEFAULT_DAYS
public static final String DATETAG_PROPERTY_YEARS
private static final String DATETAG_DEFAULT_YEARS
private String name
private String format
private boolean nice
| Constructor Detail | 
|---|
public Date(ValueStack stack)
| Method Detail | 
|---|
private TextProvider findProviderInStack()
public String formatTime(TextProvider tp,
                         Date date)
tp - text providerdate - the date
public boolean end(Writer writer,
                   String body)
Component
end in class Componentwriter - the output writer.body - the rendered body.
public void setFormat(String format)
public void setNice(boolean nice)
public String getName()
public void setName(String name)
public String getFormat()
public boolean isNice()
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||