@Test public void testValueConversion() { Date date = (Date)GoogleDataProtocolAPI.convertValue(null, "Date(2001,0,1)", SpreadsheetColumnType.DATE); assertEquals("2001-01-01", date.toString()); Timestamp ts = (Timestamp)GoogleDataProtocolAPI.convertValue(null, "Date(2001,0,1,1,2,3)", SpreadsheetColumnType.DATETIME); assertEquals("2001-01-01 01:02:03.0", ts.toString()); Time t = (Time)GoogleDataProtocolAPI.convertValue(null, Arrays.asList(1.0, 2.0, 3.0, 4.0), SpreadsheetColumnType.TIMEOFDAY); assertEquals("01:02:03", t.toString()); }
static Object convertValue(Calendar cal, Object object, SpreadsheetColumnType type) { switch (type) { case DATE: case DATETIME: if (object instanceof String) { String stringVal = (String)object; if (stringVal.startsWith("Date(") && stringVal.endsWith(")")) { String[] parts = stringVal.substring(5, stringVal.length() - 1).split(","); if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); if (type == SpreadsheetColumnType.DATETIME) { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2]), Integer.valueOf(parts[3]), Integer.valueOf(parts[4]), Integer.valueOf(parts[5])); object = new Timestamp(cal.getTimeInMillis()); } else { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2])); object = new Date(cal.getTimeInMillis()); } } } break; case TIMEOFDAY: if (object instanceof List<?>) { List<Double> doubleVals = (List<Double>)object; if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.HOUR, doubleVals.get(0).intValue()); cal.set(Calendar.MINUTE, doubleVals.get(1).intValue()); cal.set(Calendar.SECOND, doubleVals.get(2).intValue()); cal.set(Calendar.MILLISECOND, doubleVals.get(3).intValue()); object = new Time(cal.getTimeInMillis()); } break; } return object; }
GoogleDataProtocolAPI { static Object convertValue(Calendar cal, Object object, SpreadsheetColumnType type) { switch (type) { case DATE: case DATETIME: if (object instanceof String) { String stringVal = (String)object; if (stringVal.startsWith("Date(") && stringVal.endsWith(")")) { String[] parts = stringVal.substring(5, stringVal.length() - 1).split(","); if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); if (type == SpreadsheetColumnType.DATETIME) { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2]), Integer.valueOf(parts[3]), Integer.valueOf(parts[4]), Integer.valueOf(parts[5])); object = new Timestamp(cal.getTimeInMillis()); } else { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2])); object = new Date(cal.getTimeInMillis()); } } } break; case TIMEOFDAY: if (object instanceof List<?>) { List<Double> doubleVals = (List<Double>)object; if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.HOUR, doubleVals.get(0).intValue()); cal.set(Calendar.MINUTE, doubleVals.get(1).intValue()); cal.set(Calendar.SECOND, doubleVals.get(2).intValue()); cal.set(Calendar.MILLISECOND, doubleVals.get(3).intValue()); object = new Time(cal.getTimeInMillis()); } break; } return object; } }
GoogleDataProtocolAPI { static Object convertValue(Calendar cal, Object object, SpreadsheetColumnType type) { switch (type) { case DATE: case DATETIME: if (object instanceof String) { String stringVal = (String)object; if (stringVal.startsWith("Date(") && stringVal.endsWith(")")) { String[] parts = stringVal.substring(5, stringVal.length() - 1).split(","); if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); if (type == SpreadsheetColumnType.DATETIME) { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2]), Integer.valueOf(parts[3]), Integer.valueOf(parts[4]), Integer.valueOf(parts[5])); object = new Timestamp(cal.getTimeInMillis()); } else { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2])); object = new Date(cal.getTimeInMillis()); } } } break; case TIMEOFDAY: if (object instanceof List<?>) { List<Double> doubleVals = (List<Double>)object; if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.HOUR, doubleVals.get(0).intValue()); cal.set(Calendar.MINUTE, doubleVals.get(1).intValue()); cal.set(Calendar.SECOND, doubleVals.get(2).intValue()); cal.set(Calendar.MILLISECOND, doubleVals.get(3).intValue()); object = new Time(cal.getTimeInMillis()); } break; } return object; }  }
GoogleDataProtocolAPI { static Object convertValue(Calendar cal, Object object, SpreadsheetColumnType type) { switch (type) { case DATE: case DATETIME: if (object instanceof String) { String stringVal = (String)object; if (stringVal.startsWith("Date(") && stringVal.endsWith(")")) { String[] parts = stringVal.substring(5, stringVal.length() - 1).split(","); if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); if (type == SpreadsheetColumnType.DATETIME) { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2]), Integer.valueOf(parts[3]), Integer.valueOf(parts[4]), Integer.valueOf(parts[5])); object = new Timestamp(cal.getTimeInMillis()); } else { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2])); object = new Date(cal.getTimeInMillis()); } } } break; case TIMEOFDAY: if (object instanceof List<?>) { List<Double> doubleVals = (List<Double>)object; if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.HOUR, doubleVals.get(0).intValue()); cal.set(Calendar.MINUTE, doubleVals.get(1).intValue()); cal.set(Calendar.SECOND, doubleVals.get(2).intValue()); cal.set(Calendar.MILLISECOND, doubleVals.get(3).intValue()); object = new Time(cal.getTimeInMillis()); } break; } return object; }  AuthHeaderFactory getHeaderFactory(); void setHeaderFactory(AuthHeaderFactory headerFactory); RowsResult executeQuery(String spreadsheetKey, String worksheetTitle,
            String query, int batchSize, Integer offset, Integer limit); List<Column> getMetadata(String key, String worksheetTitle); }
GoogleDataProtocolAPI { static Object convertValue(Calendar cal, Object object, SpreadsheetColumnType type) { switch (type) { case DATE: case DATETIME: if (object instanceof String) { String stringVal = (String)object; if (stringVal.startsWith("Date(") && stringVal.endsWith(")")) { String[] parts = stringVal.substring(5, stringVal.length() - 1).split(","); if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); if (type == SpreadsheetColumnType.DATETIME) { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2]), Integer.valueOf(parts[3]), Integer.valueOf(parts[4]), Integer.valueOf(parts[5])); object = new Timestamp(cal.getTimeInMillis()); } else { cal.set(Integer.valueOf(parts[0]), Integer.valueOf(parts[1]), Integer.valueOf(parts[2])); object = new Date(cal.getTimeInMillis()); } } } break; case TIMEOFDAY: if (object instanceof List<?>) { List<Double> doubleVals = (List<Double>)object; if (cal == null) { cal = Calendar.getInstance(); } cal.clear(); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.HOUR, doubleVals.get(0).intValue()); cal.set(Calendar.MINUTE, doubleVals.get(1).intValue()); cal.set(Calendar.SECOND, doubleVals.get(2).intValue()); cal.set(Calendar.MILLISECOND, doubleVals.get(3).intValue()); object = new Time(cal.getTimeInMillis()); } break; } return object; }  AuthHeaderFactory getHeaderFactory(); void setHeaderFactory(AuthHeaderFactory headerFactory); RowsResult executeQuery(String spreadsheetKey, String worksheetTitle,
            String query, int batchSize, Integer offset, Integer limit); List<Column> getMetadata(String key, String worksheetTitle); static String ENCODING; }