01: package org.bpmscript.web;
02:
03: import java.text.MessageFormat;
04: import java.util.Date;
05:
06: public class Formatter {
07:
08: private String dateFormat = "{0,date,dd/MM/yy hh:mm:ss}";
09:
10: public String shorten(String value, String elipses, int max) {
11: if (value == null)
12: return value;
13: if (value.length() < max)
14: return value;
15: return value.substring(0, max) + elipses;
16: }
17:
18: public String format(String pattern, Object value) {
19: return MessageFormat.format(pattern, value);
20: }
21:
22: public String formatDate(Date date) {
23: return MessageFormat.format(dateFormat, date);
24: }
25:
26: public void setDateFormat(String dateFormat) {
27: this.dateFormat = dateFormat;
28: }
29: }
|