Changeset 278
- Timestamp:
- 03/14/06 13:37:12
- Files:
-
- trunk/calendar3/appcommon/src/org/bedework/appcommon/CalendarInfo.java (modified) (3 diffs)
- trunk/calendar3/appcommon/src/org/bedework/appcommon/DateTimeFormatter.java (modified) (5 diffs)
- trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java (modified) (1 diff)
- trunk/calendar3/appcommon/src/org/bedework/appcommon/MyCalendarVO.java (modified) (3 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java (modified) (5 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/HibSession.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java (modified) (4 diffs)
- trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/MethodBase.java (modified) (2 diffs)
- trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java (modified) (2 diffs)
- trunk/calendar3/lib/ical4j-0.9.18x.jar (modified) (previous)
- trunk/calendar3/lib/source (added)
- trunk/calendar3/lib/source/ical4j-0.9.18x-src.zip (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/appcommon/src/org/bedework/appcommon/CalendarInfo.java
r31 r278 32 32 import java.text.DateFormat; 33 33 import java.text.FieldPosition; 34 import java.text.SimpleDateFormat;34 //import java.text.SimpleDateFormat; 35 35 import java.util.ArrayList; 36 36 import java.util.Calendar; 37 import java.util.Date; 37 38 import java.util.Locale; 38 39 … … 96 97 */ 97 98 98 SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE", getLocale());99 SimpleDateFormat shortDayFormat = new SimpleDateFormat("E", getLocale());99 // SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE", getLocale()); 100 // SimpleDateFormat shortDayFormat = new SimpleDateFormat("E", getLocale()); 100 101 101 102 Calendar c = Calendar.getInstance(getLocale()); … … 119 120 c.set(Calendar.DAY_OF_WEEK, i + 1); 120 121 121 dayNames[i] = dayFormat.format(c.getTime()); 122 shortDayNames[i] = shortDayFormat.format(c.getTime()); 122 Date dt = c.getTime(); 123 dayNames[i] = DateTimeFormatter.getDayName(dt, getLocale()); 124 shortDayNames[i] = DateTimeFormatter.getShortDayName(dt, getLocale()); 123 125 dow.add(dayNames[i]); 124 126 sdow.add(shortDayNames[i]); trunk/calendar3/appcommon/src/org/bedework/appcommon/DateTimeFormatter.java
r274 r278 65 65 import java.text.DateFormat; 66 66 import java.text.FieldPosition; 67 import java.text.SimpleDateFormat; 67 68 import java.util.Calendar; 69 import java.util.Date; 68 70 import java.util.GregorianCalendar; 69 71 import java.util.HashMap; … … 87 89 /* What we store in the table */ 88 90 private static class Formatters { 91 DateFormat dayFormatter; 92 DateFormat shortDayFormatter; 93 89 94 DateFormat longDateFormatter; 90 95 DateFormat shortDateFormatter; … … 92 97 93 98 Formatters(Locale loc) { 99 dayFormatter = new SimpleDateFormat("EEEE", loc); 100 shortDayFormatter = new SimpleDateFormat("E", loc); 101 94 102 longDateFormatter = DateFormat.getDateInstance(DateFormat.LONG, loc); 95 103 shortDateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, loc); … … 368 376 } 369 377 378 /** Get a short String representation of the day represented by the parameter 379 * 380 * @param val Date 381 * @param loc Locale 382 * @return String Short representation of the day 383 * represented by this object. 384 */ 385 public static String getShortDayName(Date val, Locale loc) { 386 Formatters fmt = getFormatters(loc); 387 388 synchronized (fmt) { 389 return fmt.shortDayFormatter.format(val); 390 } 391 } 392 393 /** Get a String representation of the day represented by the parameter 394 * 395 * @param val Date 396 * @param loc Locale 397 * @return String Representation of the day represented by this object. 398 */ 399 public static String getDayName(Date val, Locale loc) { 400 Formatters fmt = getFormatters(loc); 401 402 synchronized (fmt) { 403 return fmt.dayFormatter.format(val); 404 } 405 } 406 370 407 /** Get a short String representation of the date 371 408 * … … 411 448 return fmt; 412 449 } 450 451 private static Formatters getFormatters(Locale loc) { 452 Formatters fmt = (Formatters)formattersTbl.get(loc); 453 454 if (fmt == null) { 455 fmt = new Formatters(loc); 456 formattersTbl.put(loc, fmt); 457 } 458 459 return fmt; 460 } 413 461 } trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java
r251 r278 172 172 173 173 /** Get the event's ending date and time. If the value is a date only object 174 * we decrement the date by 1 day to comply with accepted practice - that i ,174 * we decrement the date by 1 day to comply with accepted practice - that is, 175 175 * the displayed date for a 1 day event has the end date equal to the start. 176 176 * trunk/calendar3/appcommon/src/org/bedework/appcommon/MyCalendarVO.java
r251 r278 53 53 private Calendar calendar; 54 54 55 private static CalendarInfo calInfo; 56 57 private DateFormat isoformat = new SimpleDateFormat("yyyyMMdd");55 private static CalendarInfo calInfo; // XXX locale - should be table with locale as key 56 57 private static DateFormat isoformat = new SimpleDateFormat("yyyyMMdd"); 58 58 59 59 /** Create a MyCalendarVO object representing a particular date and time … … 344 344 */ 345 345 public String getDateDigits() { 346 return getFormattedDateString(isoformat); 346 synchronized (isoformat) { 347 return getFormattedDateString(isoformat); 348 } 347 349 } 348 350 … … 540 542 */ 541 543 public boolean isSameDate(MyCalendarVO that) { 542 return getFormattedDateString(isoformat).equals( 543 that.getFormattedDateString(isoformat)); 544 synchronized (isoformat) { 545 return getFormattedDateString(isoformat).equals( 546 that.getFormattedDateString(isoformat)); 547 } 544 548 } 545 549 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java
r191 r278 115 115 116 116 if (tzinfo == null) { 117 tzinfo = new TimezoneInfo(tz , vtz);117 tzinfo = new TimezoneInfo(tz); 118 118 timezones.put(tzid, tzinfo); 119 119 } else { 120 tzinfo.init(tz , vtz);120 tzinfo.init(tz); 121 121 } 122 122 } … … 136 136 } 137 137 138 tzinfo = new TimezoneInfo(new TimeZone(vTimeZone) , vTimeZone);138 tzinfo = new TimezoneInfo(new TimeZone(vTimeZone)); 139 139 timezones.put(id, tzinfo); 140 140 } … … 158 158 TimezoneInfo tzinfo = lookup(id); 159 159 160 if ((tzinfo != null) && (tzinfo.get Vtz() != null)) {161 return tzinfo.get Vtz();160 if ((tzinfo != null) && (tzinfo.getTz().getVTimeZone() != null)) { 161 return tzinfo.getTz().getVTimeZone(); 162 162 } 163 163 … … 167 167 } 168 168 169 tzinfo = new TimezoneInfo(new TimeZone(vTimeZone), vTimeZone); 170 timezones.put(id, tzinfo); 169 if (tzinfo != null) { 170 tzinfo.init(new TimeZone(vTimeZone)); 171 } else { 172 tzinfo = new TimezoneInfo(new TimeZone(vTimeZone)); 173 timezones.put(id, tzinfo); 174 } 171 175 172 176 return vTimeZone; … … 212 216 } 213 217 214 tzinfo = new TimezoneInfo(new TimeZone(vtz), vtz, true); 218 /* Don't save the vtimezone, there are a lot and it's a significant 219 * amount of space. We probably only look at 2-3 of them after this. 220 * The find timezone method will look it up again if requested and 221 * cache it at that point. 222 */ 223 tzinfo = new TimezoneInfo(new TimeZone(vtz), true); 215 224 systemTimezones.put(btz.getTzid(), tzinfo); 216 225 } trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/HibSession.java
r257 r278 91 91 /** Exception from this session. */ 92 92 Throwable exc; 93 94 private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); 93 95 94 96 /** Set up for a hibernate interaction. Throw the object away on exception. … … 475 477 try { 476 478 // Remove any time component 477 java.sql.Date dt = java.sql.Date.valueOf(478 new SimpleDateFormat("yyyy-MM-dd").format(parVal));479 q.setDate(parName, dt);479 synchronized (dateFormatter) { 480 q.setDate(parName, java.sql.Date.valueOf(dateFormatter.format(parVal))); 481 } 480 482 } catch (Throwable t) { 481 483 handleException(t); trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java
r191 r278 87 87 TimeZone tz; 88 88 89 /* If tz was derived from a db object, this is the data */90 VTimeZone vtz;91 92 89 boolean publick; 93 90 94 91 /** 95 92 * @param tz 96 * @param vtz97 93 */ 98 public TimezoneInfo(TimeZone tz , VTimeZone vtz) {99 init(tz , vtz);94 public TimezoneInfo(TimeZone tz) { 95 init(tz); 100 96 } 101 97 … … 103 99 * 104 100 * @param tz 105 * @param vtz106 101 * @param publick 107 102 */ 108 public TimezoneInfo(TimeZone tz, VTimeZone vtz, boolean publick) { 109 this.tz = tz; 110 this.vtz = vtz; 103 public TimezoneInfo(TimeZone tz, boolean publick) { 104 init(tz); 111 105 this.publick = publick; 112 106 } … … 117 111 * @param vtz 118 112 */ 119 public void init(TimeZone tz , VTimeZone vtz) {113 public void init(TimeZone tz) { 120 114 this.tz = tz; 121 this.vtz = vtz;122 115 } 123 116 124 117 public TimeZone getTz() { 125 118 return tz; 126 }127 128 public VTimeZone getVtz() {129 return vtz;130 119 } 131 120 … … 186 175 187 176 if (tzinfo == null) { 188 tzinfo = new TimezoneInfo(timezone , null);177 tzinfo = new TimezoneInfo(timezone); 189 178 timezones.put(id, tzinfo); 190 179 } else { trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/MethodBase.java
r2 r278 110 110 public abstract void init(); 111 111 112 private SimpleDateFormat httpDateFormatter = 113 new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss "); 114 112 115 /** 113 116 * @param req … … 463 466 } 464 467 465 return new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss ").format(val) + "GMT"; 468 synchronized (httpDateFormatter) { 469 return httpDateFormatter.format(val) + "GMT"; 470 } 466 471 } 467 472 trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java
r191 r278 134 134 135 135 if (tzinfo == null) { 136 tzinfo = new TimezoneInfo(tz , vtz);136 tzinfo = new TimezoneInfo(tz); 137 137 timezones.put(tzid, tzinfo); 138 138 } else { 139 tzinfo.init(tz , vtz);139 tzinfo.init(tz); 140 140 } 141 141 } … … 169 169 TimezoneInfo tzinfo = lookup(id); 170 170 171 if ((tzinfo != null) && (tzinfo.get Vtz() != null)) {172 return tzinfo.get Vtz();171 if ((tzinfo != null) && (tzinfo.getTz().getVTimeZone() != null)) { 172 return tzinfo.getTz().getVTimeZone(); 173 173 } 174 174
