View Javadoc

1   /*
2    * $Id: Ms2dateTimeFunction.java 1419 2010-11-01 14:12:17Z hoheisel $
3    *
4    * Copyright (c) 2005, The K-Wf Grid Consortium
5    * Fraunhofer Institute for Computer Architecture and Software Technology
6    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
7    */
8   
9   package net.kwfgrid.gwes.jaxen;
10  
11  import org.jaxen.Context;
12  import org.jaxen.FunctionCallException;
13  import org.jaxen.Function;
14  import org.jaxen.function.NumberFunction;
15  
16  import java.util.List;
17  
18  /**
19   * Converts date time in Milliseconds from 1970 to string.
20   * Input: Double, output: String.
21   * @author Andreas Hoheisel
22   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
23   * @version $Id: Ms2dateTimeFunction.java 1419 2010-11-01 14:12:17Z hoheisel $
24   */
25  public class Ms2dateTimeFunction implements Function {
26  
27      public Object call(Context context, List args) throws FunctionCallException {
28          if (args.isEmpty()) throw new FunctionCallException("Argument missing.");
29          if (args.size() > 1) throw new FunctionCallException("Too many arguments.");
30          Double dms = (Double)args.get(0);
31          long ms = dms.longValue();
32          TimeScheme time = new TimeScheme(ms);
33          return time.getDateTime();
34      }
35  
36  }