Changeset 273

Show
Ignore:
Timestamp:
03/09/06 14:08:02
Author:
douglm
Message:

Synchronize access to non-thread safe date/time formatters
Make a message debug only
Make a class Serializable

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java

    r251 r273  
    284284    String end = endDt.getDate(); 
    285285     
    286     debugMsg("Did UTC stuff in " + (System.currentTimeMillis() - millis)); 
     286    if (debug) { 
     287      debugMsg("Did UTC stuff in " + (System.currentTimeMillis() - millis)); 
     288    } 
    287289 
    288290    //if (debug) { 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java

    r27 r273  
    6565import java.net.URLEncoder; 
    6666import java.text.DateFormat; 
    67 import java.text.ParseException; 
    6867import java.text.SimpleDateFormat; 
    6968import java.util.ArrayList; 
     
    125124   */ 
    126125  public static String isoDate(Date val) { 
    127     return isoDateFormat.format(val); 
     126    synchronized (isoDateFormat) { 
     127      return isoDateFormat.format(val); 
     128    } 
    128129  } 
    129130 
     
    134135   */ 
    135136  public static String isoDateTime(Date val) { 
    136     return isoDateTimeFormat.format(val); 
     137    synchronized (isoDateTimeFormat) { 
     138      return isoDateTimeFormat.format(val); 
     139    } 
    137140  } 
    138141 
     
    143146   */ 
    144147  public static String isoDateTimeUTC(Date val) { 
    145     return isoDateTimeUTCFormat.format(val); 
     148    synchronized (isoDateTimeUTCFormat) { 
     149      return isoDateTimeUTCFormat.format(val); 
     150    } 
    146151  } 
    147152 
     
    154159  public static Date fromISODate(String val) throws CalFacadeException { 
    155160    try { 
    156       return isoDateFormat.parse(val); 
     161      synchronized (isoDateFormat) { 
     162        return isoDateFormat.parse(val); 
     163      } 
    157164    } catch (Throwable t) { 
    158165      throw new CalFacadeBadDateException(); 
     
    168175  public static Date fromISODateTime(String val) throws CalFacadeException { 
    169176    try { 
    170       return isoDateTimeFormat.parse(val); 
     177      synchronized (isoDateTimeFormat) { 
     178        return isoDateTimeFormat.parse(val); 
     179      } 
     180    } catch (Throwable t) { 
     181      throw new CalFacadeBadDateException(); 
     182    } 
     183  } 
     184 
     185  /** Get Date from "yyyyMMddThhmmssZ" 
     186   * 
     187   * @param val String "yyyyMMddThhmmssZ" 
     188   * @return Date 
     189   * @throws CalFacadeException 
     190   */ 
     191  public static Date fromISODateTimeUTC(String val) throws CalFacadeException { 
     192    try { 
     193      synchronized (isoDateTimeUTCFormat) { 
     194        return isoDateTimeUTCFormat.parse(val); 
     195      } 
    171196    } catch (Throwable t) { 
    172197      throw new CalFacadeBadDateException(); 
     
    182207  public static boolean isISODate(String val) throws CalFacadeException { 
    183208    try { 
    184       isoDateFormat.parse(val); 
     209      fromISODate(val); 
    185210      return true; 
    186211    } catch (Throwable t) { 
     
    197222  public static boolean isISODateTimeUTC(String val) throws CalFacadeException { 
    198223    try { 
    199       isoDateTimeUTCFormat.parse(val); 
     224      fromISODateTimeUTC(val); 
    200225      return true; 
    201226    } catch (Throwable t) { 
     
    212237  public static boolean isISODateTime(String val) throws CalFacadeException { 
    213238    try { 
    214       isoDateTimeFormat.parse(val); 
     239      fromISODateTime(val); 
    215240      return true; 
    216241    } catch (Throwable t) { 
     
    231256    try { 
    232257      if (val.getDateType()) { 
    233         return isoDateFormat.parse(dtval); 
     258        return fromISODate(dtval); 
    234259      } 
    235260 
    236261      if (dtval.endsWith("Z")) { 
    237         return isoDateTimeUTCFormat.parse(dtval); 
    238       } 
    239  
    240       return isoDateTimeFormat.parse(dtval); 
     262        return fromISODateTimeUTC(dtval); 
     263      } 
     264 
     265      return fromISODateTime(dtval); 
    241266    } catch (Throwable t) { 
    242267      throw new CalFacadeBadDateException(); 
     
    300325 
    301326    try { 
    302       dt = isoDateTimeUTCFormat.parse(val); 
     327      dt = fromISODateTimeUTC(val); 
    303328      UTC = true; 
    304     } catch (ParseException pe1) { 
     329    } catch (CalFacadeBadDateException bde1) { 
    305330      try { 
    306         dt = isoDateTimeFormat.parse(val); 
    307       } catch (ParseException pe2) { 
     331        dt = fromISODateTime(val); 
     332      } catch (CalFacadeBadDateException bde2) { 
    308333        try { 
    309           dt = isoDateFormat.parse(val); 
     334          dt = fromISODate(val); 
    310335          dateOnly = true; 
     336        } catch (CalFacadeException ce) { 
     337          throw ce; 
    311338        } catch (Throwable t) { 
    312339          throw new CalFacadeException(t); 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/EntityDates.java

    r27 r273  
    5555package org.bedework.webcommon; 
    5656 
     57import java.io.Serializable; 
     58 
    5759import org.bedework.appcommon.CalendarInfo; 
    5860import org.bedework.calsvci.CalSvcI; 
     
    6668 * This is the base class for entity specific classes. 
    6769 */ 
    68 public class EntityDates
     70public class EntityDates implements Serializable
    6971  protected boolean debug; 
    7072