On 08/01/2012 06:04 PM, Tomas Lestach wrote:
> Hello Johannes,
> 
> I somehow misread the javadoc you linked in your original e-mail.
> I made some quick tests and applied your original patch. :-)
> 
> spacewalk.git: 3bc5907dd0f669fb391701188055102433d65e9f

It looks like we might have to rollback the above commit:

We got a bugreport stating that the schedule tab shows all scheduled
action times in GMT, no matter what timezone the user has configured.
We could reproduce this only on Oracle based installations though,
apparently the GMT conversion in the above commit does not really
work when using the Postgres JDBC driver..

Attached is a patch rolling back the above commit, but fixing the
package build times by interpreting them as GMT. These are written
to the DB as GMT, as you can see here:

/backend/server/importlib/headerSource.py (line 59)

...
# A UNIX timestamp
val = gmtime(val)
...

Regards,
Johannes

-- 
SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer

>From 95e80666b5c3c163dd5c0d4763efa61ebea60ee6 Mon Sep 17 00:00:00 2001
From: Johannes Renner <jren...@suse.de>
Date: Tue, 12 Feb 2013 18:05:51 +0100
Subject: [PATCH] Only package build times should be converted to GMT

---
 .../redhat/rhn/common/db/datasource/CachedStatement.java |    3 +--
 .../code/src/com/redhat/rhn/frontend/dto/PackageDto.java |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 3 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 714868e..4977414 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
@@ -798,8 +798,7 @@ public class CachedStatement {
                         .getCanonicalName())) ||
                                 ("oracle.sql.TIMESTAMPTZ".equals(columnValue.getClass()
                         .getCanonicalName()))) {
-            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
-            return rs.getTimestamp(columnName, cal);
+            return rs.getTimestamp(columnName);
         }
         else if (columnValue instanceof BigDecimal) {
             return rs.getLong(columnName);
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/PackageDto.java b/java/code/src/com/redhat/rhn/frontend/dto/PackageDto.java
index 3622f3f..8ed4ff3 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/PackageDto.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/PackageDto.java
@@ -14,12 +14,16 @@
  */
 package com.redhat.rhn.frontend.dto;
 
+import com.redhat.rhn.common.RhnRuntimeException;
 import com.redhat.rhn.common.hibernate.HibernateFactory;
 import com.redhat.rhn.common.util.CompressionUtil;
 import com.redhat.rhn.frontend.xmlrpc.packages.PackageHelper;
 
 import java.sql.Blob;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.TimeZone;
 /**
  * PackageDto
  * @version $Rev$
@@ -262,11 +266,19 @@ public class PackageDto extends BaseDto {
     }
 
     /**
+     * Package build times are written to the database as GMT (see headerSource.py),
+     * which means we have to parse in here as long as this is not changed!
      *
      * @param buildTimeIn The buildTime to set.
      */
     public void setBuildTime(Date buildTimeIn) {
-        this.buildTime = buildTimeIn;
+        SimpleDateFormat dateFormatGMT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
+        dateFormatGMT.setTimeZone(TimeZone.getTimeZone("GMT"));
+        try {
+            this.buildTime = dateFormatGMT.parse(buildTimeIn.toString());
+        } catch (ParseException e) {
+            throw new RhnRuntimeException(e);
+        }
     }
 
     /**
-- 
1.7.10.4


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

Reply via email to