1 10 package mondrian.udf; 11 12 import mondrian.olap.Evaluator; 13 import mondrian.olap.Syntax; 14 import mondrian.olap.type.StringType; 15 import mondrian.olap.type.Type; 16 import mondrian.spi.UserDefinedFunction; 17 import mondrian.util.*; 18 19 import java.util.*; 20 21 30 public class CurrentDateStringUdf implements UserDefinedFunction { 31 32 public Object execute(Evaluator evaluator, Argument[] arguments) { 33 Object arg = arguments[0].evaluateScalar(evaluator); 34 35 final Locale locale = Locale.getDefault(); 36 final Format format = new Format((((String ) arg).toString()), locale); 37 Date currDate = new Date(); 38 return format.format(currDate); 39 } 40 41 public String getDescription() { 42 return "Returns the current date formatted as specified by the format parameter."; 43 } 44 45 public String getName() { 46 return "CurrentDateString"; 47 } 48 49 public Type[] getParameterTypes() { 50 return new Type[] { new StringType() }; 51 } 52 53 public String [] getReservedWords() { 54 return null; 55 } 56 57 public Type getReturnType(Type[] parameterTypes) { 58 return new StringType(); 59 } 60 61 public Syntax getSyntax() { 62 return Syntax.Function; 63 } 64 65 } 66 67 | Popular Tags |