View Javadoc

1   /*
2    * $Id: Ms2dayFunction.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.Function;
12  import org.jaxen.Context;
13  import org.jaxen.FunctionCallException;
14  import org.jaxen.function.NumberFunction;
15  
16  import java.util.List;
17  import java.util.Calendar;
18  
19  /**
20   * Converts date time in Milliseconds from 1970 to Double, representing the day of month.
21   * Input: Double, output: Double.
22   * @author Andreas Hoheisel
23   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
24   * @version $Id: Ms2dayFunction.java 1419 2010-11-01 14:12:17Z hoheisel $
25   */
26  public class Ms2dayFunction implements Function {
27  
28      public Object call(Context context, List args) throws FunctionCallException {
29          if (args.isEmpty()) throw new FunctionCallException("Argument missing.");
30          if (args.size() > 1) throw new FunctionCallException("Too many arguments.");
31          Double dms = (Double)args.get(0);
32          long ms = dms.longValue();
33          TimeScheme time = new TimeScheme(ms);
34          Integer ivalue = time.getCal().get(Calendar.DAY_OF_MONTH);
35          return ivalue.doubleValue();
36      }
37  
38  }