add parseDate() with format
This commit is contained in:
parent
f8aa1e1d0c
commit
7166ab805c
2 changed files with 17 additions and 1 deletions
|
@ -78,11 +78,15 @@ public class FessFunctions {
|
|||
}
|
||||
|
||||
public static Date parseDate(final String value) {
|
||||
return parseDate(value, Constants.ISO_DATETIME_FORMAT);
|
||||
}
|
||||
|
||||
public static Date parseDate(final String value, String format) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(Constants.ISO_DATETIME_FORMAT);
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
sdf.setTimeZone(Constants.TIMEZONE_UTC);
|
||||
return sdf.parse(value);
|
||||
} catch (final ParseException e) {
|
||||
|
|
|
@ -59,6 +59,18 @@
|
|||
</example>
|
||||
</function>
|
||||
|
||||
<function>
|
||||
<description>
|
||||
Returns Date from a given value.
|
||||
</description>
|
||||
<name>parseDateFormat</name>
|
||||
<function-class>org.codelibs.fess.taglib.FessFunctions</function-class>
|
||||
<function-signature>java.util.Date parseDate(java.lang.String, java.lang.String)</function-signature>
|
||||
<example>
|
||||
${fe:parseDate(doc.tstamp, "yyyy-MM-dd HH:mm:ss")}
|
||||
</example>
|
||||
</function>
|
||||
|
||||
<function>
|
||||
<description>
|
||||
Returns formatted number from a given value.
|
||||
|
|
Loading…
Add table
Reference in a new issue