Examples of DateTimeValue


Examples of com.google.visualization.datasource.datatable.value.DateTimeValue

    assertEquals(new NumberValue(2008), year.evaluate(dateValues));
    assertEquals(new NumberValue(7), month.evaluate(dateValues));
    assertEquals(new NumberValue(13), day.evaluate(dateValues));

    List<Value> dateTimeValues =
        Lists.newArrayList((Value) new DateTimeValue(
            2001, 2, 3, 9, 12, 22, 333));
    assertEquals(new NumberValue(2001), year.evaluate(dateTimeValues));
    assertEquals(new NumberValue(2), month.evaluate(dateTimeValues));
    assertEquals(new NumberValue(3), day.evaluate(dateTimeValues));
    assertEquals(new NumberValue(9), hour.evaluate(dateTimeValues));
    assertEquals(new NumberValue(12), minute.evaluate(dateTimeValues));
    assertEquals(new NumberValue(22), second.evaluate(dateTimeValues));
    assertEquals(new NumberValue(333), millisecond.evaluate(dateTimeValues));

    List<Value> timeOfDayValues =
        Lists.newArrayList((Value) new TimeOfDayValue(23, 22, 21, 20));
    assertEquals(new NumberValue(23), hour.evaluate(timeOfDayValues));
    assertEquals(new NumberValue(22), minute.evaluate(timeOfDayValues));
    assertEquals(new NumberValue(21), second.evaluate(timeOfDayValues));
    assertEquals(new NumberValue(20), millisecond.evaluate(timeOfDayValues));
    timeOfDayValues = Lists.newArrayList((Value) new TimeOfDayValue(9, 12, 22));
    // Tests that milliseconds return 0 when the the TimeOfDayValue is
    // initialized without the milliseconds.
    assertEquals(new NumberValue(0), millisecond.evaluate(timeOfDayValues));

    List<Value> dateValues1 =
        Lists.newArrayList((Value) new DateValue(2008, 1, 13));
    List<Value> dateValues2 =
        Lists.newArrayList((Value) new DateValue(2008, 4, 13));
    List<Value> dateValues3 =
        Lists.newArrayList((Value) new DateValue(2008, 8, 13));
    List<Value> dateValues4 =
        Lists.newArrayList((Value) new DateValue(2008, 11, 13));
    List<Value> dateValues5 =
        Lists.newArrayList((Value) new DateValue(2008, 5, 13));

    assertEquals(new NumberValue(1), quarter.evaluate(dateValues1));
    assertEquals(new NumberValue(2), quarter.evaluate(dateValues2));
    assertEquals(new NumberValue(3), quarter.evaluate(dateValues3));
    assertEquals(new NumberValue(4), quarter.evaluate(dateValues4));
    assertEquals(new NumberValue(2), quarter.evaluate(dateValues5));

    assertEquals(new NumberValue(4), dayofweek.evaluate(dateValues1));
    assertEquals(new NumberValue(3), dayofweek.evaluate(dateValues2));
    assertEquals(new NumberValue(7), dayofweek.evaluate(dateValues3));
    assertEquals(new NumberValue(7), dayofweek.evaluate(dateValues4));
    assertEquals(new NumberValue(6), dayofweek.evaluate(dateValues5));

    List<Value> dateTimeValues1 =
        Lists.newArrayList((Value) new DateTimeValue(
            2001, 0, 3, 9, 12, 22, 333));
    List<Value> dateTimeValues2 =
        Lists.newArrayList((Value) new DateTimeValue(
            2001, 3, 3, 9, 12, 22, 333));
    List<Value> dateTimeValues3 =
        Lists.newArrayList((Value) new DateTimeValue(
            2001, 8, 3, 9, 12, 22, 333));
    List<Value> dateTimeValues4 =
        Lists.newArrayList((Value) new DateTimeValue(
            2001, 10, 3, 9, 12, 22, 333));
    List<Value> dateTimeValues5 =
        Lists.newArrayList((Value) new DateTimeValue(
            2001, 7, 3, 9, 12, 22, 333));

    assertEquals(new NumberValue(1), quarter.evaluate(dateTimeValues1));
    assertEquals(new NumberValue(2), quarter.evaluate(dateTimeValues2));
    assertEquals(new NumberValue(3), quarter.evaluate(dateTimeValues3));
View Full Code Here

Examples of com.google.visualization.datasource.datatable.value.DateTimeValue

    ToDate toDate = ToDate.getInstance();
    List<Value> valuesList1 =
        Lists.<Value>newArrayList(new DateValue(2008, 1, 13));
    List<Value> valuesList2 =
        Lists.<Value>newArrayList(
            new DateTimeValue(2008, 2, 23, 9, 12, 22, 333));
    List<Value> valuesList3 =
        Lists.<Value>newArrayList(new NumberValue(1234567890000.53421423424));
List<Value> valuesList4 =
        Lists.<Value>newArrayList(new NumberValue(-1234567890000.0));
    assertEquals(new DateValue(2008, 1, 13), toDate.evaluate(valuesList1));
View Full Code Here

Examples of com.google.visualization.datasource.datatable.value.DateTimeValue

    row.addCell(new TableCell("aaa"));
    row.addCell(new TableCell(222));
    row.addCell(new TableCell(false));
    row.addCell(new TableCell(new DateValue(2001, 10, 14)));
    row.addCell(new TableCell(new TimeOfDayValue(12, 11, 13, 14)));
    row.addCell(new TableCell(new DateTimeValue(2000, 10, 1, 1, 10, 23, 432)));
    rows.add(row);

    row = new TableRow();
    row.addCell(new TableCell("ccc"));
    row.addCell(new TableCell(111));
    row.addCell(new TableCell(true));
    row.addCell(new TableCell(new DateValue(2001, 1, 14)));
    row.addCell(new TableCell(new TimeOfDayValue(12, 30, 13, 14)));
    row.addCell(new TableCell(new DateTimeValue(1000, 11, 1, 1, 10, 23, 432)));
    rows.add(row);

    row = new TableRow();
    row.addCell(new TableCell("bbb"));
    row.addCell(new TableCell(3));
    row.addCell(new TableCell(true));
    row.addCell(new TableCell(new DateValue(2012, 2, 14)));
    row.addCell(new TableCell(new TimeOfDayValue(12, 11, 3, 14)));
    row.addCell(new TableCell(new DateTimeValue(2000, 1, 1, 1, 10, 31, 4)));
    rows.add(row);

    row = new TableRow();
    row.addCell("ddd");
    row.addCell(222);
    row.addCell(false);
    row.addCell(new DateValue(1997, 5, 5));
    row.addCell(new TimeOfDayValue(12, 15, 15, 14));
    row.addCell(new DateTimeValue(3100, 1, 2, 15, 15, 1, 0));
    rows.add(row);

    testData.addRows(rows);
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.value.DateTimeValue

    TableRow row = new TableRow();
    row.addCell(new TableCell(new TextValue("aaa"), "aaa"));
    row.addCell(new TableCell(new NumberValue(222), "222"));
    row.addCell(new TableCell(BooleanValue.TRUE, "true"));
    row.addCell(new TableCell(new DateValue(2009, 1, 1), "2009-02-01"));
    row.addCell(new TableCell(new DateTimeValue(2009, 1, 1, 12, 14, 1, 0), "2009-02-01 12:14:01"));
    row.addCell(new TableCell(new TimeOfDayValue(12, 14, 1), "12:14:01"));
    rows.add(row);
   
    row = new TableRow();
    row.addCell(new TableCell(new TextValue("aaa"), "a,aa"));
    row.addCell(new TableCell(new NumberValue(222), "2,22"));
    row.addCell(new TableCell(BooleanValue.TRUE, "true,"));
    row.addCell(new TableCell(new DateValue(2009, 1, 1), "2009-02-01"));
    row.addCell(new TableCell(new DateTimeValue(2009, 1, 1, 12, 14, 1, 0), "2009-02-01 12,14,01"));
    row.addCell(new TableCell(new TimeOfDayValue(12, 14, 1), "12:14:01"));
    rows.add(row);
   
    testData.addRows(rows);
   
View Full Code Here

Examples of com.volantis.xml.expression.atomic.temporal.DateTimeValue

       
        Value result = Sequence.EMPTY;
        if (arguments[0].getSequence() != Sequence.EMPTY) {
            DurationValue duration = context.getFactory().createDurationValue(
                    arguments[0].stringValue().asJavaString());
            DateTimeValue dateTime = CurrentDateTimeHelper
                    .getCurrentDateTimeValue(context);
            DateTimeValue newDateTime = ((SimpleDateTimeValue) dateTime)
                    .add(duration);
            long seconds = (newDateTime.getCalendar().getTimeInMillis() - dateTime
                    .getCalendar().getTimeInMillis()) / 1000;
            result = context.getFactory().createIntValue((int) seconds);
        }
        return result;
    }
View Full Code Here

Examples of com.volantis.xml.expression.atomic.temporal.DateTimeValue

     *                {@link DateTimeValue} instance
     * @return new date time value for current date and time
     */
    public static DateTimeValue getCurrentDateTimeValue(
            ExpressionContext context) {
        DateTimeValue value = (DateTimeValue) context.getProperty(
                DateTimeValue.class);
        if (value == null) {
            final TimeZone timeZone = (TimeZone) context.getProperty(
                    TimeZone.class);
            final Calendar calendar;
View Full Code Here

Examples of com.volantis.xml.expression.atomic.temporal.DateTimeValue

        }
        ExpressionFactory factory = context.getFactory();
        SimpleDateTimeValue first = (SimpleDateTimeValue)
                factory.createDateTimeValue(
                        arguments[0].stringValue().asJavaString());
        DateTimeValue second = factory.createDateTimeValue(
                arguments[1].stringValue().asJavaString());
        return first.subtract(second);
    }
View Full Code Here

Examples of net.sf.saxon.value.DateTimeValue

  }
 
  public static AtomicValue convertToAtomicValue(Object value) throws TransformerException {
    if (value instanceof java.util.Date) { //special handling for time types
          java.util.Date d = (java.util.Date)value;
          DateTimeValue tdv = DateTimeValue.fromJavaDate(d);
          if (value instanceof Date) {
            value = new DateValue(tdv.getYear(), tdv.getMonth(), tdv.getDay(), tdv.getTimezoneInMinutes());
          } else if (value instanceof Time) {
            value = new TimeValue(tdv.getHour(), tdv.getMinute(), tdv.getSecond(), tdv.getMicrosecond(), tdv.getTimezoneInMinutes());
          } else if (value instanceof Timestamp) {
            Timestamp ts = (Timestamp)value;
            value = tdv.add(DayTimeDurationValue.fromMicroseconds(ts.getNanos() / 1000));
          }
          return (AtomicValue)value;
        }
    JPConverter converter = JPConverter.allocate(value.getClass(), null);
    return (AtomicValue)converter.convert(value, null);
View Full Code Here

Examples of net.sf.saxon.value.DateTimeValue

                    break;
                case GYEAR_CODE:
                    valueStr = FunctionMethods.format((BigInteger)value, GYEAR_FORMAT);
                    break;
                case GYEARMONTH_CODE:
        DateTimeValue dtv;
        try {
          dtv = ((DateTimeValue)XMLSystemFunctions.convertToAtomicValue(value));
        } catch (TransformerException e) {
          throw new TransformationException(e, e.getMessage());
        }
                  valueStr = new GYearMonthValue(dtv.getYear(), dtv.getMonth(), dtv.getTimezoneInMinutes()).getStringValue();
                    break;
                default:
                    valueStr = defaultTranslation(value);
                    break;
            }
View Full Code Here

Examples of net.sf.saxon.value.DateTimeValue

    private Object getSimpleContent(Node simpleNode, QName type) {
        String text = simpleNode.getTextContent();
        try {
        Object jobj = XSTypes.toJavaObject(type,text);
            // Saxon wants its own dateTime type and doesn't like Calendar or Date
            if (jobj instanceof Calendar) return new DateTimeValue((Calendar) jobj, true);
            else return jobj;
        } catch (Exception e) { }
        // Elegant way failed, trying brute force
      try {
        return Integer.valueOf(text);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.