Hi,

We experienced a problem with rpm metadata generation: the taskomatic generated
build times of packages are different from the actual build times that are 
stored
in the rpm package. You should experience that problem as well.

We are wondering if it can be generally assumed that all of the values written 
to
date fields in the Database are converted to UTC beforehands? In this case we 
might
want to fix CachedStatement.java (method getObject()), so it will not put the 
local
timezone as default for all Date objects created using rs.getTimestamp() (only 
in
case the DB does not provide info about the timezone!).

A generic fix could maybe look like the attached patch, see here for javadoc of
the proposed method:

http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSet.html#getTimestamp%28java.lang.String,%20java.util.Calendar%29

Otherwise we could also fix the package build times only, and do so in
PackageDto.setBuildTime(). What do you think?

Thanks,
Johannes

-- 
SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
>From 861cf5c634c611f19ed509fb96126adb5f4cea19 Mon Sep 17 00:00:00 2001
From: Johannes Renner <jren...@suse.de>
Date: Mon, 30 Jul 2012 17:12:06 +0200
Subject: [PATCH] Construct GMT millisecond value for timestamp if DB does not
 store timezone

---
 .../rhn/common/db/datasource/CachedStatement.java  |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java b/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java
index ab472a0..7133ec1 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java
@@ -37,6 +37,7 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -45,6 +46,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.TimeZone;
 
 /**
  * A cached set of query/elaborator strings and the parameterMap hash maps.
@@ -772,7 +774,8 @@ public class CachedStatement {
         // this            : August 23, 2005 12:00:00 AM PDT
         // vs the real date: August 23, 2005 1:36:12 PM PDT
         if (columnValue instanceof Date) {
-            return rs.getTimestamp(columnName);
+            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+            return rs.getTimestamp(columnName, cal);
         }
         else if (columnValue instanceof BigDecimal) {
             return rs.getLong(columnName);
-- 
1.7.7

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to