diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/ConnectionImpl.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/ConnectionImpl.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/ConnectionImpl.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/ConnectionImpl.java 2014-05-13 10:57:00.000000000 +0100 @@ -743,8 +743,11 @@ this.isRunningOnJDK13 = true; } - this.sessionCalendar = new GregorianCalendar(); - this.utcCalendar = new GregorianCalendar(); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + this.sessionCalendar = prolepticGregorianCalendar; + this.utcCalendar = (Calendar) prolepticGregorianCalendar.clone(); this.utcCalendar.setTimeZone(TimeZone.getTimeZone("GMT")); // diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/EscapeProcessor.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/EscapeProcessor.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/EscapeProcessor.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/EscapeProcessor.java 2014-05-13 10:55:54.000000000 +0100 @@ -386,7 +386,10 @@ sessionCalendar = conn .getCalendarInstanceForSessionOrNew(); } else { - sessionCalendar = new GregorianCalendar(); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + sessionCalendar = prolepticGregorianCalendar; } try { @@ -462,6 +465,10 @@ SimpleDateFormat tsdf = new SimpleDateFormat( "''yyyy-MM-dd HH:mm:ss", Locale.US); //$NON-NLS-1$ + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + tsdf.setCalendar(prolepticGregorianCalendar); + tsdf .setTimeZone(conn .getServerTimezoneTZ()); @@ -532,7 +539,10 @@ sessionCalendar = conn .getCalendarInstanceForSessionOrNew(); } else { - sessionCalendar = new GregorianCalendar(); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + sessionCalendar = prolepticGregorianCalendar; sessionCalendar .setTimeZone(TimeZone .getTimeZone("GMT")); diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/PreparedStatement.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/PreparedStatement.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/PreparedStatement.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/PreparedStatement.java 2014-05-13 10:54:25.000000000 +0100 @@ -53,6 +53,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.GregorianCalendar; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -2019,6 +2020,11 @@ public String getDateTime(String pattern){ SimpleDateFormat sdf = new SimpleDateFormat(pattern); + + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + sdf.setCalendar(prolepticGregorianCalendar); + return sdf.format(new java.util.Date()); } @@ -3587,6 +3593,11 @@ // not thread-safe :( SimpleDateFormat dateFormatter = new SimpleDateFormat( "''yyyy-MM-dd''", Locale.US); //$NON-NLS-1$ + + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + dateFormatter.setCalendar(prolepticGregorianCalendar); + setInternal(parameterIndex, dateFormatter.format(x)); this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATE; @@ -4130,6 +4141,11 @@ ParsePosition pp = new ParsePosition(0); java.text.DateFormat sdf = new java.text.SimpleDateFormat( getDateTimePattern((String) parameterObj, false), Locale.US); + + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + sdf.setCalendar(prolepticGregorianCalendar); + parameterAsDate = sdf.parse((String) parameterObj, pp); } else { parameterAsDate = (java.util.Date) parameterObj; @@ -4169,6 +4185,7 @@ if (parameterObj instanceof String) { java.text.DateFormat sdf = new java.text.SimpleDateFormat( getDateTimePattern((String) parameterObj, true), Locale.US); + setTime(parameterIndex, new java.sql.Time(sdf.parse( (String) parameterObj).getTime())); } else if (parameterObj instanceof Timestamp) { @@ -4704,6 +4721,10 @@ synchronized (this) { if (this.tsdf == null) { this.tsdf = new SimpleDateFormat("''yyyy-MM-dd HH:mm:ss", Locale.US); //$NON-NLS-1$ + + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + this.tsdf.setCalendar(prolepticGregorianCalendar); } StringBuffer buf = new StringBuffer(); @@ -4736,6 +4757,10 @@ synchronized (checkClosed().getConnectionMutex()) { if (this.tsdf == null) { this.tsdf = new SimpleDateFormat("''yyyy-MM-dd HH:mm:ss", Locale.US); //$NON-NLS-1$ + + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + this.tsdf.setCalendar(prolepticGregorianCalendar); } String timestampString = null; @@ -4789,6 +4814,10 @@ synchronized (checkClosed().getConnectionMutex()) { if (this.ddf == null) { this.ddf = new SimpleDateFormat("''yyyy-MM-dd''", Locale.US); //$NON-NLS-1$ + + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + this.ddf.setCalendar(prolepticGregorianCalendar); } String timeString = null; diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/ResultSetImpl.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/ResultSetImpl.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/ResultSetImpl.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/ResultSetImpl.java 2014-05-13 10:39:55.000000000 +0100 @@ -549,7 +549,10 @@ private synchronized void createCalendarIfNeeded() { if (this.fastDateCal == null) { - this.fastDateCal = new GregorianCalendar(Locale.US); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(Locale.US); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + this.fastDateCal = prolepticGregorianCalendar; this.fastDateCal.setTimeZone(this.getDefaultTimeZone()); } } @@ -1996,7 +1999,9 @@ } // punt, no connection around - return new GregorianCalendar(); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + return prolepticGregorianCalendar; } } diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/ServerPreparedStatement.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/ServerPreparedStatement.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/ServerPreparedStatement.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/ServerPreparedStatement.java 2014-05-13 10:41:23.000000000 +0100 @@ -2585,7 +2585,10 @@ private Calendar getServerTzCalendar() throws SQLException { synchronized (checkClosed().getConnectionMutex()) { if (serverTzCalendar == null) { - serverTzCalendar = new GregorianCalendar(this.connection.getServerTimezoneTZ()); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(this.connection.getServerTimezoneTZ()); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + serverTzCalendar = prolepticGregorianCalendar; } return this.serverTzCalendar; @@ -2595,7 +2598,10 @@ private Calendar getDefaultTzCalendar() throws SQLException { synchronized (checkClosed().getConnectionMutex()) { if (defaultTzCalendar == null) { - defaultTzCalendar = new GregorianCalendar(TimeZone.getDefault()); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(TimeZone.getDefault()); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + defaultTzCalendar = prolepticGregorianCalendar; } return this.defaultTzCalendar; diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/StatementImpl.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/StatementImpl.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/StatementImpl.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/StatementImpl.java 2014-05-13 10:42:17.000000000 +0100 @@ -1912,7 +1912,10 @@ return this.connection.getCalendarInstanceForSessionOrNew(); } // punt, no connection around - return new GregorianCalendar(); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + return prolepticGregorianCalendar; } } diff -Naur mysql-connector-java-5.1.30/src/com/mysql/jdbc/TimeUtil.java mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/TimeUtil.java --- mysql-connector-java-5.1.30/src/com/mysql/jdbc/TimeUtil.java 2014-03-11 09:39:50.000000000 +0000 +++ mysql-connector-java-5.1.30-eggyal/src/com/mysql/jdbc/TimeUtil.java 2014-05-13 10:45:56.000000000 +0100 @@ -946,7 +946,10 @@ Calendar targetCalendar, java.util.Date dt) { if (sessionCalendar == null) { - sessionCalendar = new GregorianCalendar(); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + sessionCalendar = prolepticGregorianCalendar; } // JDBC spec is not clear whether or not this @@ -1019,7 +1022,10 @@ final static Date fastDateCreate(int year, int month, int day, Calendar targetCalendar) { - Calendar dateCal = (targetCalendar == null) ? new GregorianCalendar() : targetCalendar; + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + Calendar dateCal = (targetCalendar == null) ? prolepticGregorianCalendar : targetCalendar; dateCal.clear(); @@ -1099,7 +1105,10 @@ SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); } - Calendar cal = (targetCalendar == null) ? new GregorianCalendar() : targetCalendar; + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + Calendar cal = (targetCalendar == null) ? prolepticGregorianCalendar : targetCalendar; cal.clear(); // Set 'date' to epoch of Jan 1, 1970 @@ -1171,7 +1180,12 @@ final static Timestamp fastTimestampCreate(TimeZone tz, int year, int month, int day, int hour, int minute, int seconds, int secondsPart) { - Calendar cal = (tz == null) ? new GregorianCalendar() : new GregorianCalendar(tz); + final GregorianCalendar prolepticGregorianCalendar = new GregorianCalendar(); + prolepticGregorianCalendar.setGregorianChange(new java.util.Date(Long.MIN_VALUE)); + + Calendar cal = prolepticGregorianCalendar; + if (tz != null) cal.setTimeZone(tz); + cal.clear(); // why-oh-why is this different than java.util.date,