[jsword-svn] r1285 - trunk/jsword/src/main/java/org/crosswire/jsword/book/readings

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Fri Apr 20 10:51:40 MST 2007


Author: dmsmith
Date: 2007-04-20 10:51:40 -0700 (Fri, 20 Apr 2007)
New Revision: 1285

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java
Log:
Internationalized the Readings Book, making their dates show the same as regular Daily Devotionals.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2007-04-20 17:50:32 UTC (rev 1284)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2007-04-20 17:51:40 UTC (rev 1285)
@@ -22,7 +22,6 @@
 package org.crosswire.jsword.book.readings;
 
 import java.util.Calendar;
-import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Iterator;
 import java.util.Locale;
@@ -88,9 +87,13 @@
         bmd.setInitials(setname);
         setBookMetaData(bmd);
 
-        // We use 1972 because it is a leap year.
-        Calendar greg = new GregorianCalendar(1972, Calendar.JANUARY, 1);
-        while (greg.get(Calendar.YEAR) == 1972)
+        // Go through the current year
+        Calendar greg = new GregorianCalendar();
+        greg.set(Calendar.DAY_OF_MONTH, 1);
+        greg.set(Calendar.MONDAY, Calendar.JANUARY);
+        int currentYear = greg.get(Calendar.YEAR);
+
+        while (greg.get(Calendar.YEAR) == currentYear)
         {
             String internalKey = ReadingsKey.external2internal(greg);
             String readings = ""; //$NON-NLS-1$
@@ -98,14 +101,13 @@
             try
             {
                 readings = prop.getString(internalKey);
+                hash.put(new ReadingsKey(greg.getTime()), readings);
             }
             catch (MissingResourceException e)
             {
                 log.warn("Missing resource: " + internalKey + " while parsing: " + setname); //$NON-NLS-1$ //$NON-NLS-2$
             }
 
-            hash.put(new ReadingsKey(greg.getTime()), readings);
-
             greg.add(Calendar.DATE, 1);
         }
 
@@ -117,10 +119,7 @@
      */
     public Key getPreferred()
     {
-        GregorianCalendar now = new GregorianCalendar();
-        now.setTime(new Date());
-
-        GregorianCalendar greg = new GregorianCalendar(1972, now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
+        GregorianCalendar greg = new GregorianCalendar();
         return new ReadingsKey(greg.getTime());
     }
 
@@ -141,7 +140,7 @@
 
             Element div = OSISUtil.factory().createDiv();
             Element title = OSISUtil.factory().createTitle();
-            title.addContent(Msg.HEADING.toString(key.getName()));
+            title.addContent(key.getName());
             div.addContent(title);
             text.addContent(div);
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java	2007-04-20 17:50:32 UTC (rev 1284)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java	2007-04-20 17:51:40 UTC (rev 1285)
@@ -77,6 +77,11 @@
      */
     public boolean equals(Object obj)
     {
+        if (this == obj)
+        {
+            return true;
+        }
+
         // Since this can not be null
         if (obj == null)
         {
@@ -90,14 +95,6 @@
             return false;
         }
 
-        // If super does equals ...
-        /* Commented out because super.equals() always equals false
-        if (!super.equals(obj))
-        {
-            return false;
-        }
-        */
-
         // The real bit ...
         ReadingsKey that = (ReadingsKey) obj;
 
@@ -150,12 +147,8 @@
     /**
      * Date formatter
      */
-    private static final DateFormat NAME_DF = new SimpleDateFormat("d MMMM"); //$NON-NLS-1$
+    private static final DateFormat NAME_DF = DateFormat.getDateInstance(DateFormat.MEDIUM);
     private static final DateFormat OSIS_DF = new SimpleDateFormat("d.MMMM"); //$NON-NLS-1$
-    static
-    {
-        NAME_DF.setLenient(true);
-    }
 
     private static final MessageFormat KEY_FORMAT = new MessageFormat("{0,number,00}.{1,number,00}"); //$NON-NLS-1$
 }




More information about the jsword-svn mailing list