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

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


 
  public void testReadWithLocale() throws IOException, CsvDataSourceException {
    List <ColumnDescription> columnDescriptions = Lists.newArrayList();
    columnDescriptions.add(new ColumnDescription("A", ValueType.NUMBER, "A"));
    columnDescriptions.add(new ColumnDescription("B", ValueType.TIMEOFDAY, "B"));
    TimeOfDayValue hindiTimeOfDayValue = new TimeOfDayValue(1, 12, 1);
    String hindiTimeOfDayString =  "\u0966\u0967\u003a\u0967\u0968\u003a\u0966\u0967";
    Reader reader = new StringReader("1," + hindiTimeOfDayString);
    DataTable dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false,
        new ULocale("hi_IN"));
    assertEquals(1, dataTable.getNumberOfRows());
View Full Code Here


    assertEquals("true", dataTable.getRow(2).getCell(5).getValue().toString());
    assertEquals(dataTable.getRow(0).getCell(6).getValue().toString(),
        new DateValue(gc), dataTable.getRow(0).getCell(6).getValue());
    assertEquals(new DateTimeValue(gc),
        dataTable.getRow(0).getCell(7).getValue());
    assertEquals(new TimeOfDayValue(gc),
        dataTable.getRow(0).getCell(8).getValue());
    assertEquals(DateValue.getNullValue(),
        dataTable.getRow(1).getCell(6).getValue());
    assertEquals(DateTimeValue.getNullValue(),
        dataTable.getRow(2).getCell(7).getValue());
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

    assertEquals("", JsonRenderer.renderDataTable(dataTable, true, true, true));
  }

  public void testAppendCellJson() {
    TableCell dateCell = new TableCell(new DateValue(2009, 1, 12));
    TableCell timeofdayCell = new TableCell(new TimeOfDayValue(12, 13, 14, 15));
    TableCell datetimeCell = new TableCell(new DateTimeValue(2009, 1, 12, 12, 13, 14, 15));
    TableCell booleanCell = new TableCell(true);
    TableCell numberCell = new TableCell(12.3);
    TableCell textCell = new TableCell("aba");
View Full Code Here

    String escapedFormattedString = "";
    boolean isJsonNull = false;

    // Prepare a Json string representing the current value.
    DateValue dateValue;
    TimeOfDayValue timeOfDayValue;
    if ((value == null) || (value.isNull())) {
      valueJson.append("null");
      isJsonNull = true;
    } else {
      switch (type) {
        case BOOLEAN:
          valueJson.append(((BooleanValue) value).getValue());
          break;
        case DATE:
          valueJson.append("Date(");
          dateValue = (DateValue) value;
          valueJson.append(dateValue.getYear()).append(",");
          valueJson.append(dateValue.getMonth()).append(",");
          valueJson.append(dateValue.getDayOfMonth());
          valueJson.append(")");
          if (renderDateAsDateConstructor) {
            // Rendering date as a call to Date constructor, e.g new Date(2011,1,1)
            valueJson.insert(0, "new ");
          } else {
            // Rendering date in string format, e.g "Date(2011,1,1)"
            valueJson.insert(0, "\"");
            valueJson.append("\"");          
          }
          break;
        case NUMBER:
          valueJson.append(((NumberValue) value).getValue());
          break;
        case TEXT:
          valueJson.append("\"");
          valueJson.append(EscapeUtil.jsonEscape(value.toString()));
          valueJson.append("\"");
          break;
        case TIMEOFDAY:
          valueJson.append("[");
          timeOfDayValue = (TimeOfDayValue) value;
          valueJson.append(timeOfDayValue.getHours()).append(",");
          valueJson.append(timeOfDayValue.getMinutes()).append(",");
          valueJson.append(timeOfDayValue.getSeconds()).append(",");
          valueJson.append(timeOfDayValue.getMilliseconds());
          valueJson.append("]");
          break;
        case DATETIME:
          calendar = ((DateTimeValue) value).getCalendar();
          valueJson.append("Date(");
View Full Code Here

          gc.set(1970, Calendar.JANUARY, 1, time.getHours(), time.getMinutes(),
                 time.getSeconds());
          // Set the milliseconds explicitly, otherwise the milliseconds from
          // the time the gc was initialized are used.
          gc.set(GregorianCalendar.MILLISECOND, 0);
          value = new TimeOfDayValue(gc);
        }
        break;
      default:
        String colValue = rs.getString(column);
        if (colValue == null) {
View Full Code Here

    table.addColumn(new ColumnDescription("dateTimeCol", ValueType.DATETIME, "dateTimeCol"));

    TableRow row = new TableRow();
    row.addCell(new TableCell(new DateValue(2008, 5, 3)));
    row.addCell(new TableCell(new NumberValue(23)));
    row.addCell(new TableCell(new TimeOfDayValue(13, 12, 11)));
    row.addCell(new TableCell(new DateTimeValue(2007, 3, 4, 2, 6, 23, 120)));

    // Check date value.
    List<AbstractColumn> columns =
        Lists.newArrayList((AbstractColumn) new SimpleColumn("dateCol"));
View Full Code Here

    query = QueryBuilder.getInstance().parseQuery(
        "WHERE c1 = timesTaMP '2007-01-30 15:33:22.432'");
    assertEquals(new DateTimeValue(2007, 0, 30, 15, 33, 22, 432),
        ((ColumnValueFilter) query.getFilter()).getValue());
    query = QueryBuilder.getInstance().parseQuery("WHERE c1 != TimeOfDay '15:33:22'");
    assertEquals(new TimeOfDayValue(15, 33, 22),
        ((ColumnValueFilter) query.getFilter()).getValue());
  }
View Full Code Here

        minute = Integer.parseInt(split[1]);
        if (split[2].contains(".")) {
          String[] secondMilliSplit = split[2].split("\\.");
          second = Integer.parseInt(secondMilliSplit[0]);
          milli = Integer.parseInt(secondMilliSplit[1]);
          return new TimeOfDayValue(hour, minute, second, milli);
        } else {
          second = Integer.parseInt(split[2]);
          return new TimeOfDayValue(hour, minute, second);
        }

      default:
        throw new RuntimeException("We do not support other types "
            + "for now");
View Full Code Here

            random.nextInt(60), random.nextInt(999));
      case DATE:
        return new DateValue(random.nextInt(200) + 1900, random.nextInt(12),
            random.nextInt(28) + 1);
      case TIMEOFDAY:
        return new TimeOfDayValue(random.nextInt(24), random.nextInt(60),
            random.nextInt(60), random.nextInt(999));
      default:
        throw new RuntimeException("Invalid type");
    }
  }
View Full Code Here

TOP

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

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.