@Test public void testValueParsing() throws Exception { assertEquals(TimestampUtil.createTime(2, 0, 0), QueryExecutionImpl.parseDateTime("08:00:00.000Z", Time.class, Calendar.getInstance())); }
static Object parseDateTime(String value, Class<?> type, Calendar cal) throws TranslatorException { try { Matcher m = dateTimePattern.matcher(value); if (m.matches()) { String date = m.group(1); String time = m.group(2); String timeZone = m.group(3); Date d = null; if (date == null) { int milli = time.lastIndexOf('.'); if (milli > 0) { time = time.substring(0, milli); } d = Time.valueOf(time); } else { d = Timestamp.valueOf(date + " " + time); } TimeZone tz = null; if (timeZone != null) { if (timeZone.equals("Z")) { tz = TimeZone.getTimeZone("GMT"); } else if (timeZone.contains(":")) { tz = TimeZone.getTimeZone("GMT" + timeZone); } else { tz = TimeZone.getTimeZone(timeZone); } cal.setTimeZone(tz); } else { cal = null; } return TimestampWithTimezone.create(d, TimeZone.getDefault(), cal, type); } throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } catch (IllegalArgumentException e) { throw new TranslatorException(e, SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } }
QueryExecutionImpl implements ResultSetExecution { static Object parseDateTime(String value, Class<?> type, Calendar cal) throws TranslatorException { try { Matcher m = dateTimePattern.matcher(value); if (m.matches()) { String date = m.group(1); String time = m.group(2); String timeZone = m.group(3); Date d = null; if (date == null) { int milli = time.lastIndexOf('.'); if (milli > 0) { time = time.substring(0, milli); } d = Time.valueOf(time); } else { d = Timestamp.valueOf(date + " " + time); } TimeZone tz = null; if (timeZone != null) { if (timeZone.equals("Z")) { tz = TimeZone.getTimeZone("GMT"); } else if (timeZone.contains(":")) { tz = TimeZone.getTimeZone("GMT" + timeZone); } else { tz = TimeZone.getTimeZone(timeZone); } cal.setTimeZone(tz); } else { cal = null; } return TimestampWithTimezone.create(d, TimeZone.getDefault(), cal, type); } throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } catch (IllegalArgumentException e) { throw new TranslatorException(e, SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } } }
QueryExecutionImpl implements ResultSetExecution { static Object parseDateTime(String value, Class<?> type, Calendar cal) throws TranslatorException { try { Matcher m = dateTimePattern.matcher(value); if (m.matches()) { String date = m.group(1); String time = m.group(2); String timeZone = m.group(3); Date d = null; if (date == null) { int milli = time.lastIndexOf('.'); if (milli > 0) { time = time.substring(0, milli); } d = Time.valueOf(time); } else { d = Timestamp.valueOf(date + " " + time); } TimeZone tz = null; if (timeZone != null) { if (timeZone.equals("Z")) { tz = TimeZone.getTimeZone("GMT"); } else if (timeZone.contains(":")) { tz = TimeZone.getTimeZone("GMT" + timeZone); } else { tz = TimeZone.getTimeZone(timeZone); } cal.setTimeZone(tz); } else { cal = null; } return TimestampWithTimezone.create(d, TimeZone.getDefault(), cal, type); } throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } catch (IllegalArgumentException e) { throw new TranslatorException(e, SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } } QueryExecutionImpl(QueryExpression command, SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext context, SalesForceExecutionFactory salesForceExecutionFactory); }
QueryExecutionImpl implements ResultSetExecution { static Object parseDateTime(String value, Class<?> type, Calendar cal) throws TranslatorException { try { Matcher m = dateTimePattern.matcher(value); if (m.matches()) { String date = m.group(1); String time = m.group(2); String timeZone = m.group(3); Date d = null; if (date == null) { int milli = time.lastIndexOf('.'); if (milli > 0) { time = time.substring(0, milli); } d = Time.valueOf(time); } else { d = Timestamp.valueOf(date + " " + time); } TimeZone tz = null; if (timeZone != null) { if (timeZone.equals("Z")) { tz = TimeZone.getTimeZone("GMT"); } else if (timeZone.contains(":")) { tz = TimeZone.getTimeZone("GMT" + timeZone); } else { tz = TimeZone.getTimeZone(timeZone); } cal.setTimeZone(tz); } else { cal = null; } return TimestampWithTimezone.create(d, TimeZone.getDefault(), cal, type); } throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } catch (IllegalArgumentException e) { throw new TranslatorException(e, SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } } QueryExecutionImpl(QueryExpression command, SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext context, SalesForceExecutionFactory salesForceExecutionFactory); void cancel(); void close(); @Override void execute(); @Override List<?> next(); }
QueryExecutionImpl implements ResultSetExecution { static Object parseDateTime(String value, Class<?> type, Calendar cal) throws TranslatorException { try { Matcher m = dateTimePattern.matcher(value); if (m.matches()) { String date = m.group(1); String time = m.group(2); String timeZone = m.group(3); Date d = null; if (date == null) { int milli = time.lastIndexOf('.'); if (milli > 0) { time = time.substring(0, milli); } d = Time.valueOf(time); } else { d = Timestamp.valueOf(date + " " + time); } TimeZone tz = null; if (timeZone != null) { if (timeZone.equals("Z")) { tz = TimeZone.getTimeZone("GMT"); } else if (timeZone.contains(":")) { tz = TimeZone.getTimeZone("GMT" + timeZone); } else { tz = TimeZone.getTimeZone(timeZone); } cal.setTimeZone(tz); } else { cal = null; } return TimestampWithTimezone.create(d, TimeZone.getDefault(), cal, type); } throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } catch (IllegalArgumentException e) { throw new TranslatorException(e, SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); } } QueryExecutionImpl(QueryExpression command, SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext context, SalesForceExecutionFactory salesForceExecutionFactory); void cancel(); void close(); @Override void execute(); @Override List<?> next();  }