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

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


                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

        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

            if(isReadableLetters(language)) {
                assertTrue(formattedValue.contains("88"));
            }

            // Time
            formattedValue = timeOfDayFormatter.format(new TimeOfDayValue(2, 24, 6));
            assertFalse(StringUtils.isEmpty(formattedValue));
            language = ulocale.getDisplayLanguage();
            if(isReadableLetters(language)) {
                assertTrue(formattedValue.contains("24"));
            }
View Full Code Here

        formattedValue = dateFormatter.format(new DateValue(1988, 11, 24));
        assertEquals("12 | 24 | 88", formattedValue);

        // Time
        formattedValue =
                timeFormatter.format(new TimeOfDayValue(2, 24, 6));
        assertEquals("02-24", formattedValue);

        // Timestamp
        formattedValue = timestampFormatter.format(new DateTimeValue(1597, 9, 29, 1, 2, 33, 142));
        assertEquals("29_10_97 01:02", formattedValue);
View Full Code Here

                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"));

        assertEquals(new TimeOfDayValue(12, 13, 14, 0),
                ValueFormatter.createDefault(ValueType.TIMEOFDAY, null).parse("12:13:14"));

    }
View Full Code Here

        assertEquals(DateValue.getNullValue(), dateFormatter.parse("01.15.2004"));
    }

    public void testParseTimeOfDay() {
        ValueFormatter timeOfDayFormatter = ValueFormatter.createDefault(ValueType.TIMEOFDAY, null);
        assertEquals(new TimeOfDayValue(7, 22, 44), timeOfDayFormatter.parse("7:22:44"));

        timeOfDayFormatter = ValueFormatter.createFromPattern(ValueType.TIMEOFDAY, "ss:mm:HH", null);

        assertEquals(new TimeOfDayValue(7, 22, 44), timeOfDayFormatter.parse("44:22:7"));

        assertEquals(TimeOfDayValue.getNullValue(), timeOfDayFormatter.parse("01.15.2004"));
    }
View Full Code Here

        assertEquals("", r.renderDataTable(dataTable, 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

        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

        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());
                    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

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.