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

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


        testData.addColumn(c2);

        rows = Lists.newArrayList();

        TableRow row = new TableRow();
        row.addCell(new TableCell(new DateValue(2011, 1, 1), "1/1/2011"));
        row.addCell(new TableCell(new DateTimeValue(2011, 1, 1, 0, 0, 0, 0), "1/1/2011 00:00:00"));
        row.addCell(new TableCell(new NumberValue(222), "222"));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell(new DateValue(2011, 1, 2), "1/2/2011"));
        row.addCell(new TableCell(new DateTimeValue(2011, 1, 2, 3, 15, 0, 0)));
        row.addCell(new TableCell(NumberValue.getNullValue()));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell(new DateValue(2011, 1, 3), "1/3/2011"));
        row.addCell(new TableCell(new DateTimeValue(2011, 1, 3, 3, 15, 0, 0), "1/1/2011 03:15:00"));
        row.addCell(new TableCell(333));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell(new DateValue(2011, 1, 4)));
        row.addCell(new TableCell(new DateTimeValue(2011, 1, 4, 0, 0, 0, 0)));
        row.addCell(new TableCell(222));
        rows.add(row);

        testData.addRows(rows);
View Full Code Here


        table.addColumn(new ColumnDescription("numberCol", ValueType.NUMBER, "numberCol"));
        table.addColumn(new ColumnDescription("timeOfDayCol", ValueType.TIMEOFDAY, "timeOfDayCol"));
        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.
View Full Code Here

        // If the given value is null, return a null date value.
        if(value.isNull()) {
            return DateValue.getNullValue();
        }
        DateValue dateValue;
        switch(value.getType()) {
            case DATE:
                dateValue = (DateValue) value;
                break;
            case DATETIME:
                dateValue = new DateValue((GregorianCalendar)
                        (((DateTimeValue) value).getObjectToFormat()));
                break;
            case NUMBER:
                date = new Date((long) ((NumberValue) value).getValue());
                gc.setTime(date);
                dateValue = new DateValue(gc);
                break;
            default:// Should never get here.
                throw new RuntimeException("Value type was not found: " + value.getType());
        }
        return dateValue;
View Full Code Here

        GregorianCalendar calendar;
        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(")");
                    this.appendDate(valueJson);
                    break;
                case NUMBER:
                    valueJson.append(((NumberValue) value).getValue());
View Full Code Here

                    // Set the year, month and date in the gregorian calendar.
                    // Use the 'set' method with those parameters, and not the 'setTime'
                    // method with the date parameter, since the Date object contains the
                    // current time zone and it's impossible to change it to 'GMT'.
                    gc.set(date.getYear() + 1900, date.getMonth(), date.getDate());
                    value = new DateValue(gc);
                }
                break;
            case DATETIME:
                Timestamp timestamp = rs.getTimestamp(column);
                // If timestamp is null it is handled later.
View Full Code Here

    }

    public void testGetValueFromEmptyAggregation() {
        ValueAggregator aggregator = new ValueAggregator(ValueType.DATE);
        DateValue dateNull = DateValue.getNullValue();
        NumberValue numberNull = NumberValue.getNullValue();

        assertEquals(new NumberValue(0), aggregator.getValue(AggregationType.COUNT));

        assertEquals(dateNull, aggregator.getValue(AggregationType.MIN));
View Full Code Here

            // add the date to the first cell
            final Value dateTimeValue;
            switch (dateTimeColumnType) {
                case DATE: {
                    dateTimeValue = new DateValue(rowTime.getYear(), rowTime.getMonthOfYear()-1, rowTime.getDayOfMonth());
                    break;
                }
                case TIMEOFDAY: {
                    dateTimeValue = new TimeOfDayValue(rowTime.getHourOfDay(), rowTime.getMinuteOfHour(), 0);
                    break;
View Full Code Here

    GregorianCalendar calendar;
    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("new Date(");
          dateValue = (DateValue) value;
          valueJson.append(dateValue.getYear()).append(",");
          valueJson.append(dateValue.getMonth()).append(",");
          valueJson.append(dateValue.getDayOfMonth());
          valueJson.append(")");
          break;
        case NUMBER:
          valueJson.append(((NumberValue) value).getValue());
          break;
View Full Code Here

    try {
      int year = Integer.parseInt(split[0]);
      int month = Integer.parseInt(split[1]);
      month--; // normalize 1-12 to 0-11.
      int day = Integer.parseInt(split[2]);
      return new DateValue(year, month, day);
    } catch (NumberFormatException e) {
      log.error(String.format(dateMessage, s));
      throw new InvalidQueryException(String.format(dateMessage, s));
    } catch (IllegalArgumentException e) {
      log.error(String.format(dateMessage, s));
View Full Code Here

          uFormat = new TextFormat();
          break;
        case DATE:
          uFormat = new SimpleDateFormat(pattern, locale);
          ((SimpleDateFormat) uFormat).setTimeZone(TimeZone.getTimeZone("GMT"));
          uFormat.format(new DateValue(1995, 7, 3).getObjectToFormat());
          break;
        case TIMEOFDAY:
          uFormat = new SimpleDateFormat(pattern, locale);
          ((SimpleDateFormat) uFormat).setTimeZone(TimeZone.getTimeZone("GMT"));
          uFormat.format(new TimeOfDayValue(2, 59, 12, 123).getObjectToFormat());
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.