Revision 24544 trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/ToDate.java
ToDate.java | ||
---|---|---|
21 | 21 |
} |
22 | 22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 | 23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date toDate(String value){return new java.text.SimpleDateFormat().parse(value);};"); |
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def toDate(value):\n" + |
|
25 |
" import java.text.SimpleDateFormat\n" + |
|
26 |
" sdf=instance(java.text.SimpleDateFormat)\n" + |
|
27 |
" return sdf.parse(value)"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"import java.text.DateFormat as DateFormat\n" + |
|
26 |
"import java.text.SimpleDateFormat as SimpleDateFormat\n" + |
|
27 |
"dateFormat = DateFormat.getInstance()\n" + |
|
28 |
"myDateFormat = SimpleDateFormat()\n" + |
|
29 |
"def toDate(value, format=None):\n" + |
|
30 |
" if format != None:\n"+ |
|
31 |
" myDateFormat.applyPattern(format)\n"+ |
|
32 |
" return myDateFormat.parse(value)\n"+ |
|
33 |
" return dateFormat.parse(value)"); |
|
28 | 34 |
} |
29 | 35 |
public boolean isEnable() { |
30 | 36 |
return (getType()==IOperator.DATE); |
31 | 37 |
} |
38 |
|
|
39 |
public String getTooltip(){ |
|
40 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"[,"+PluginServices.getText(this,"format")+"])"+"\n"+getDescription(); |
|
41 |
} |
|
42 |
|
|
32 | 43 |
public String getDescription() { |
33 |
return PluginServices.getText(this, "parameter") + ": " + |
|
44 |
return PluginServices.getText(this, "parameter") + "1: " +
|
|
34 | 45 |
PluginServices.getText(this, "string_value") + "\n" + |
46 |
PluginServices.getText(this, "format") + " ("+PluginServices.getText(this, "optional")+"): " + |
|
47 |
PluginServices.getText(this, "string_value") + "\n" + |
|
35 | 48 |
PluginServices.getText(this, "returns") + ": " + |
36 | 49 |
PluginServices.getText(this, "date_value") + "\n" + |
37 | 50 |
PluginServices.getText(this, "description") + ": " + |
38 |
"Returns a date object from string parameter."; |
|
51 |
"Returns a date object from string parameter formatted according to\nthe parameter format if it is supplied.\n\n"+ |
|
52 |
"The format should follow the specifications of\n" + |
|
53 |
"'http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html'.\n\n"+ |
|
54 |
"Examples: (for the date of December 23, 2008)\n"+ |
|
55 |
" 'dd/MM/yy' 23/12/08\n"+ |
|
56 |
" 'dd/MM/yyyy' 23/12/2008\n"+ |
|
57 |
" 'dd/MMM/yyyy' 23/dec/2008\n"+ |
|
58 |
" 'dd/MMMM/yyyy' 23/december/2008\n"; |
|
59 |
|
|
39 | 60 |
} |
40 | 61 |
} |
Also available in: Unified diff