java/code/src/com/redhat/rhn/common/localization/LocalizationService.java | 16
++++++++++
java/code/src/com/redhat/rhn/frontend/action/channel/ChannelDetailsAction.java | 3 +
java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java | 4 --
java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp | 2 -
4 files changed, 21 insertions(+), 4 deletions(-)
New commits:
commit 3c434176a55e6015d18ade5ab1301540e02ec246
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Apr 7 23:02:23 2010 +0200
580227 - displaying dates in the same format
using time zone the user has set in locale preferencies
and displaying (kind of original) custom date format
diff --git a/java/code/src/com/redhat/rhn/common/localization/LocalizationService.java
b/java/code/src/com/redhat/rhn/common/localization/LocalizationService.java
index 0fbe392..30b87d7 100644
--- a/java/code/src/com/redhat/rhn/common/localization/LocalizationService.java
+++ b/java/code/src/com/redhat/rhn/common/localization/LocalizationService.java
@@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
import java.text.Collator;
import java.text.DateFormat;
import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -59,6 +60,7 @@ public class LocalizationService {
* into java.util.Dates so they can be formatted based on Locale.
*/
public static final String RHN_DB_DATEFORMAT = "yyyy-MM-dd HH:mm:ss";
+ public static final String RHN_CUSTOM_DATEFORMAT = "yyyy-MM-dd HH:mm:ss
z";
private static Logger log = Logger.getLogger(LocalizationService.class);
private static Logger msgLogger = Logger
@@ -433,6 +435,20 @@ public class LocalizationService {
}
/**
+ * Returns fixed custom format string displayed for the determined timezone
+ * Example: 2010-04-01 15:04:24 CEST
+ *
+ * @param date Date to format.
+ * @return String representation of given date for set timezone
+ */
+ public String formatCustomDate(Date date) {
+ TimeZone tz = determineTimeZone();
+ SimpleDateFormat sdf = new SimpleDateFormat(RHN_CUSTOM_DATEFORMAT);
+ sdf.setTimeZone(tz);
+ return sdf.format(date);
+ }
+
+ /**
* Format the Number based on the locale and convert it to a String to
* display.
* @param numberIn Number to format.
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelDetailsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelDetailsAction.java
index ac34c32..fd4978e 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelDetailsAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelDetailsAction.java
@@ -14,6 +14,7 @@
*/
package com.redhat.rhn.frontend.action.channel;
+import com.redhat.rhn.common.localization.LocalizationService;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.role.RoleFactory;
@@ -81,6 +82,8 @@ public class ChannelDetailsAction extends RhnAction {
request.setAttribute("pack_size",
ChannelFactory.getPackageCount(chan));
request.setAttribute("globally",
chan.isGloballySubscribable(user.getOrg()));
request.setAttribute("channel", chan);
+ request.setAttribute("channel_last_modified", LocalizationService.
+ getInstance().formatCustomDate(chan.getLastModified()));
//Check if the channel needed repodata,
// if so get the status and last build info
if (chan.isChannelRepodataRequired()) {
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index 66a51ee..466088d 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -2782,9 +2782,7 @@ public class ChannelManager extends BaseManager {
// the file Modified date should be getting set when the file
// is moved into the correct location.
log.info("File Modified Date:" + fileModifiedDateIn);
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- String fileModifiedDate = formatter.format(fileModifiedDateIn);
- return fileModifiedDate;
+ return LocalizationService.getInstance().formatCustomDate(fileModifiedDateIn);
}
diff --git a/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
b/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
index b4038cd..d484c92 100644
--- a/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
@@ -83,7 +83,7 @@
</tr>
<tr>
<th><bean:message
key="channelfiles.jsp.lastmod"/>:</th>
- <td><c:out value="${channel.lastModified}" /></td>
+ <td><c:out value="${channel_last_modified}" /></td>
</tr>
<tr>
<th><bean:message
key="channel.jsp.repolastbuild"/>:</th>
Show replies by date