roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ko...@apache.org
Subject svn commit: r1680521 - in /roller/trunk/app/src/main/java/org/apache/roller: util/ weblogger/business/jpa/ weblogger/ui/core/tags/calendar/ weblogger/ui/rendering/pagers/
Date Wed, 20 May 2015 11:06:27 GMT
Author: kohei
Date: Wed May 20 11:06:26 2015
New Revision: 1680521

URL: http://svn.apache.org/r1680521
Log:
ROL-2076 Links based on date wrongly produced on multi-timezone environment

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/util/DateUtil.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/BigWeblogCalendarModel.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/CalendarTag.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/util/DateUtil.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/util/DateUtil.java?rev=1680521&r1=1680520&r2=1680521&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/util/DateUtil.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/util/DateUtil.java Wed May 20 11:06:26
2015
@@ -469,14 +469,26 @@ public abstract class DateUtil {
     public static String format8chars(Date date) {
         return format(date, get8charDateFormat());
     }
-    
-    
+
+    // convenience method returns 8 char day stamp YYYYMMDD using time zone
+    public static String format8chars(Date date, TimeZone tz) {
+        SimpleDateFormat formatter = get8charDateFormat();
+        formatter.setTimeZone(tz);
+        return format(date, formatter);
+    }
+
     // convenience method returns 6 char month stamp YYYYMM
     public static String format6chars(Date date) {
         return format(date, get6charDateFormat());
     }
-    
-    
+
+    // convenience method returns 6 char month stamp YYYYMM using time zone
+    public static String format6chars(Date date, TimeZone tz) {
+        SimpleDateFormat formatter = get6charDateFormat();
+        formatter.setTimeZone(tz);
+        return format(date, formatter);
+    }
+
     // convenience method returns long friendly formatted timestamp
     public static String formatIso8601Day(Date date) {
         return format(date, getIso8601DayDateFormat());

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java?rev=1680521&r1=1680520&r2=1680521&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
Wed May 20 11:06:26 2015
@@ -788,11 +788,13 @@ public class JPAWeblogEntryManagerImpl i
         List<WeblogEntry> entries = getWeblogEntries(wesc);
 
         Calendar cal = Calendar.getInstance();
+        SimpleDateFormat formatter = DateUtil.get8charDateFormat();
         if (wesc.getWeblog() != null) {
-            cal.setTimeZone(wesc.getWeblog().getTimeZoneInstance());
+            TimeZone tz = wesc.getWeblog().getTimeZoneInstance();
+            cal.setTimeZone(tz);
+            formatter.setTimeZone(tz);
         }
 
-        SimpleDateFormat formatter = DateUtil.get8charDateFormat();
         for (WeblogEntry entry : entries) {
             Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
             if (map.get(sDate) == null) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/BigWeblogCalendarModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/BigWeblogCalendarModel.java?rev=1680521&r1=1680520&r2=1680521&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/BigWeblogCalendarModel.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/BigWeblogCalendarModel.java
Wed May 20 11:06:26 2015
@@ -22,6 +22,8 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.TimeZone;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -39,16 +41,19 @@ import org.apache.roller.util.DateUtil;
 public class BigWeblogCalendarModel extends WeblogCalendarModel {
     
     private static Log mLogger = LogFactory.getLog(BigWeblogCalendarModel.class);
-    
+
     protected final SimpleDateFormat starDateFormat =
             DateUtil.get8charDateFormat();
-    
+
     protected final SimpleDateFormat singleDayFormat =
             new SimpleDateFormat("dd");
-    
-    
+
+
     public BigWeblogCalendarModel(WeblogPageRequest pRequest, String cat) {
         super(pRequest, cat);
+        TimeZone tz = weblog.getTimeZoneInstance();
+        starDateFormat.setTimeZone(tz);
+        singleDayFormat.setTimeZone(tz);
     }
     
     

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/CalendarTag.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/CalendarTag.java?rev=1680521&r1=1680520&r2=1680521&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/CalendarTag.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/tags/calendar/CalendarTag.java
Wed May 20 11:06:26 2015
@@ -156,6 +156,7 @@ public class CalendarTag extends TagSupp
 
             // formatter Month-Year title of calendar
             SimpleDateFormat formatTitle = new SimpleDateFormat(bundle.getString("calendar.dateFormat"),
mLocale);
+            formatTitle.setTimeZone(todayCal.getTimeZone());
             
             // go back to first day in month
             cal = model.getCalendar();

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java?rev=1680521&r1=1680520&r2=1680521&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
Wed May 20 11:06:26 2015
@@ -26,6 +26,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.TimeZone;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.business.WebloggerFactory;
@@ -69,15 +70,18 @@ public class WeblogEntriesDayPager exten
             int                page) {
         
         super(strat, weblog, locale, pageLink, entryAnchor, dateString, catName, tags, page);
-        
+
+        TimeZone tz = weblog.getTimeZoneInstance();
+
         dayFormat = new SimpleDateFormat(
             messageUtils.getString("weblogEntriesPager.day.dateFormat"));
+        dayFormat.setTimeZone(tz);
         
         getEntries();
         
         day = parseDate(dateString);
-        
-        Calendar cal = Calendar.getInstance();
+
+        Calendar cal = Calendar.getInstance(tz);
         
         cal.setTime(day);
         cal.add(Calendar.DAY_OF_MONTH, 1);
@@ -199,7 +203,7 @@ public class WeblogEntriesDayPager exten
     
     public String getNextCollectionLink() {
         if (nextDay != null) {
-            String next = DateUtil.format8chars(nextDay);
+            String next = DateUtil.format8chars(nextDay, weblog.getTimeZoneInstance());
             return createURL(0, 0, weblog, locale, pageLink, null, next, catName, tags);
         }
         return null;
@@ -216,7 +220,7 @@ public class WeblogEntriesDayPager exten
     
     public String getPrevCollectionLink() {
         if (prevDay != null) {
-            String prev = DateUtil.format8chars(prevDay);
+            String prev = DateUtil.format8chars(prevDay, weblog.getTimeZoneInstance());
             return createURL(0, 0, weblog, locale, pageLink, null, prev, catName, tags);
         }
         return null;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java?rev=1680521&r1=1680520&r2=1680521&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
Wed May 20 11:06:26 2015
@@ -19,13 +19,8 @@
 package org.apache.roller.weblogger.ui.rendering.pagers;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.business.WebloggerFactory;
@@ -69,15 +64,18 @@ public class WeblogEntriesMonthPager ext
             int                page) {
         
         super(strat, weblog, locale, pageLink, entryAnchor, dateString, catName, tags, page);
-        
+
+        TimeZone tz = weblog.getTimeZoneInstance();
+
         monthFormat = new SimpleDateFormat(
             messageUtils.getString("weblogEntriesPager.month.dateFormat"));
+        monthFormat.setTimeZone(tz);
         
         getEntries();
         
         month = parseDate(dateString);
         
-        Calendar cal = Calendar.getInstance();
+        Calendar cal = Calendar.getInstance(tz);
         
         cal.setTime(month);
         cal.add(Calendar.MONTH, 1);
@@ -193,7 +191,7 @@ public class WeblogEntriesMonthPager ext
     
     public String getNextCollectionLink() {
         if (nextMonth != null) {
-            String next = DateUtil.format6chars(nextMonth);
+            String next = DateUtil.format6chars(nextMonth, weblog.getTimeZoneInstance());
             return createURL(0, 0, weblog, locale, pageLink, null, next, catName, tags);
         }
         return null;
@@ -210,7 +208,7 @@ public class WeblogEntriesMonthPager ext
     
     public String getPrevCollectionLink() {
         if (prevMonth != null) {
-            String prev = DateUtil.format6chars(prevMonth);
+            String prev = DateUtil.format6chars(prevMonth, weblog.getTimeZoneInstance());
             return createURL(0, 0, weblog, locale, pageLink, null, prev, catName, tags);
         }
         return null;



Mime
View raw message