Package com.google.visualization.datasource.datatable.value

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


  // differently than in English.
  // The following is a simple example for Hindi.
  public void testHindiLocale() {
    ValueFormatter dateFormatter = ValueFormatter.createFromPattern(
        ValueType.DATE, "MM | dd | yyyy", new ULocale("hi_IN"));
    DateValue dateValue = new DateValue(2009, 1, 2);
    String dateString =
        "\u0966\u0968\u0020\u007c\u0020\u0966\u0968\u0020\u007c\u0020\u0968\u0966\u0966\u096f";
    assertEquals(dateString, dateFormatter.format(dateValue));
    assertEquals(dateValue, dateFormatter.parse(dateString));
  }
View Full Code Here


        ValueFormatter.createDefault(ValueType.TEXT, null).parse("1a"));

    assertEquals(BooleanValue.TRUE,
        ValueFormatter.createDefault(ValueType.BOOLEAN, null).parse("true"));

    assertEquals(new DateValue(2009, Calendar.JANUARY, 1),
        ValueFormatter.createDefault(ValueType.DATE, null).parse("2009-1-1"));

    assertEquals(new DateTimeValue(2009, Calendar.JANUARY, 1, 12, 13, 14, 0),
        ValueFormatter.createDefault(ValueType.DATETIME, null).parse("2009-1-1 12:13:14"));
View Full Code Here

  }

  public void testParseDate() {
    ValueFormatter dateFormatter = ValueFormatter.createDefault(ValueType.DATE, null);

    assertEquals(new DateValue(2004, Calendar.FEBRUARY, 15),
        dateFormatter.parse("2004-02-15"));
    dateFormatter = ValueFormatter.createFromPattern(ValueType.DATE, "MM/dd/yyyy", null);
    assertEquals(new DateValue(2004, Calendar.JANUARY, 15), dateFormatter.parse("01/15/2004"));
    assertEquals(DateValue.getNullValue(), dateFormatter.parse("01.15.2004"));
  }
View Full Code Here

    TableRow row = new TableRow();
    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

  }

  public void testEvaluate() {
    DateDiff dateDiff = DateDiff.getInstance();
    List<Value> valuesList1 =
        Lists.<Value>newArrayList(new DateValue(2008, 1, 13),
            new DateValue(2008, 2, 13));
    List<Value> valuesList2 = Lists.newArrayList(new DateValue(2008, 1, 13),
            new DateTimeValue(2008, 1, 13, 9, 12, 22, 333));
    List<Value> valuesList3 =
        Lists.<Value>newArrayList(new DateTimeValue(2008, 6, 1, 9, 12, 22, 333),
            new DateTimeValue(2008, 10, 1, 9, 12, 22, 333));
    List<Value> valuesList4 = Lists.<Value>newArrayList(new DateTimeValue(
View Full Code Here

    }
  }

  public void testEvaluate() {
    List<Value> dateValues =
        Lists.newArrayList((Value) new DateValue(2008, 7, 13));
    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));
View Full Code Here

  }

  public void testEvaluate() {
    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));
    assertEquals(new DateValue(2008, 2, 23), toDate.evaluate(valuesList2));
    assertEquals(new DateValue(2009, 1, 13), toDate.evaluate(valuesList3));
    assertEquals(new DateValue(1930, 10, 18), toDate.evaluate(valuesList4));

  }
View Full Code Here

        BooleanValue.FALSE));

    // Test type mismatch:
    assertFalse(greaterThanFilter.isOperatorMatch(new TextValue("blah"),
        new NumberValue(123)));
    assertFalse(equalsFilter.isOperatorMatch(new DateValue(2000, 3, 3),
        BooleanValue.TRUE));
  }
View Full Code Here

    TableRow row = new TableRow();
    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

    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

TOP

Related Classes of com.google.visualization.datasource.datatable.value.DateValue

Copyright © 2018 www.massapicom. 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.