[kune-commits] r1701 - in trunk/src/main/java/cc/kune: common/client/utils events/client/viewer events/server events/shared
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Thu Feb 23 14:17:09 CET 2012
Author: vjrj_
Date: 2012-02-23 14:17:09 +0100 (Thu, 23 Feb 2012)
New Revision: 1701
Added:
trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java
Removed:
trunk/src/main/java/cc/kune/events/server/DateServerUtils.java
trunk/src/main/java/cc/kune/events/server/EventsServerConversionUtil.java
trunk/src/main/java/cc/kune/events/shared/DateUtils.java
Modified:
trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java
Log:
Copied: trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java (from rev 1698, trunk/src/main/java/cc/kune/events/shared/DateUtils.java)
===================================================================
--- trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java 2012-02-23 13:17:09 UTC (rev 1701)
@@ -0,0 +1,40 @@
+package cc.kune.common.client.utils;
+
+import java.util.Date;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
+
+/**
+ * The Class DateUtils try to follow ISO_8601 (previously RFC 2445 date-time
+ * formats).
+ */
+public class DateUtils {
+
+ private static DateTimeFormat iso_8601 = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
+ // Sample DTSTART:19980118T230000
+ private static DateTimeFormat rfcDateFormat = DateTimeFormat.getFormat("'DTSTART':yyyyMMdd'T'Hmmss");
+
+ public static Date toDate(final String date) {
+ try {
+ return iso_8601.parse(date);
+ } catch (final IllegalArgumentException e) {
+ try {
+ return rfcDateFormat.parse(date);
+ } catch (final IllegalArgumentException e1) {
+ // try old (buggy) hour formats
+ // DTSTART:20120229T120000
+ try {
+ return DateTimeFormat.getFormat("'DTSTART':yyyyMMdd'T'hhmmss").parse(date);
+ } catch (final IllegalArgumentException e2) {
+ // DTSTART:20120225T1300
+ return DateTimeFormat.getFormat("'DTSTART':yyyyMMdd'T'hhmm").parse(date);
+ }
+ }
+ }
+ }
+
+ public static String toString(final Date date) {
+ return iso_8601.format(date);
+ }
+}
Modified: trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java 2012-02-23 02:57:00 UTC (rev 1700)
+++ trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java 2012-02-23 13:17:09 UTC (rev 1701)
@@ -9,6 +9,7 @@
import cc.kune.common.client.actions.ui.descrip.Position;
import cc.kune.common.client.log.Log;
import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.client.utils.DateUtils;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.common.shared.res.ICalConstants;
import cc.kune.common.shared.utils.TextUtils;
@@ -19,7 +20,6 @@
import cc.kune.core.shared.dto.HasContent;
import cc.kune.core.shared.dto.StateEventContainerDTO;
import cc.kune.events.client.actions.CalendarOnOverMenu;
-import cc.kune.events.shared.DateUtils;
import cc.kune.events.shared.EventsClientConversionUtil;
import cc.kune.events.shared.EventsConstants;
import cc.kune.gspace.client.viewers.AbstractFolderViewerView;
Deleted: trunk/src/main/java/cc/kune/events/server/DateServerUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/DateServerUtils.java 2012-02-23 02:57:00 UTC (rev 1700)
+++ trunk/src/main/java/cc/kune/events/server/DateServerUtils.java 2012-02-23 13:17:09 UTC (rev 1701)
@@ -1,26 +0,0 @@
-package cc.kune.events.server;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * The Class DateUtils try to follow RFC 2445 date-time formats.
- *
- * DTSTART;TZID=US-Eastern:19970714T133000 ;Local time and time ; zone reference
- */
-public class DateServerUtils {
-
- private static String RFC_DATE_TIME_FORMAT = "'DTSTART':yyyyMMdd'T'hhmmss";
- // This is not tested: better use some class conversion util...
- private static String RFC_DATE_TIME_FORMAT_TZ = "'DTSTART;TZID='z:yyyyMMdd'T'hhmmss";
- private static SimpleDateFormat rfcDateFormat = new SimpleDateFormat(RFC_DATE_TIME_FORMAT);
-
- public static Date toDate(final String date) throws ParseException {
- return rfcDateFormat.parse(date);
- }
-
- public static String toString(final Date date) {
- return rfcDateFormat.format(date);
- }
-}
Deleted: trunk/src/main/java/cc/kune/events/server/EventsServerConversionUtil.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/EventsServerConversionUtil.java 2012-02-23 02:57:00 UTC (rev 1700)
+++ trunk/src/main/java/cc/kune/events/server/EventsServerConversionUtil.java 2012-02-23 13:17:09 UTC (rev 1701)
@@ -1,44 +0,0 @@
-package cc.kune.events.server;
-
-import java.text.ParseException;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import cc.kune.common.shared.res.ICalConstants;
-import cc.kune.events.shared.EventsSharedConversionUtil;
-
-import com.bradrydzewski.gwt.calendar.client.Appointment;
-
-/**
- * The Class EventsConversionUtil is used to convert Appointments to Gadgets
- * properties and viceversa
- */
-public class EventsServerConversionUtil extends EventsSharedConversionUtil {
- private static final Logger LOG = Logger.getLogger(EventsServerConversionUtil.class.getName());
-
- public static Appointment toApp(final Map<String, String> properties) {
- final Appointment app = EventsSharedConversionUtil.toApp(properties);
- try {
- final String start = properties.get(ICalConstants.DATE_TIME_START);
- if (start != null) {
- app.setStart(DateServerUtils.toDate(start));
- }
- final String end = properties.get(ICalConstants.DATE_TIME_END);
- if (end != null) {
- app.setEnd(DateServerUtils.toDate(end));
- }
- } catch (final ParseException e) {
- LOG.log(Level.SEVERE, "Error parsing event", e);
- }
- return app;
- }
-
- public static Map<String, String> toMap(final Appointment app) {
- final Map<String, String> properties = EventsSharedConversionUtil.toMap(app);
- properties.put(ICalConstants.DATE_TIME_START, DateServerUtils.toString(app.getStart()));
- properties.put(ICalConstants.DATE_TIME_END, DateServerUtils.toString(app.getEnd()));
- return properties;
- }
-
-}
Deleted: trunk/src/main/java/cc/kune/events/shared/DateUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/events/shared/DateUtils.java 2012-02-23 02:57:00 UTC (rev 1700)
+++ trunk/src/main/java/cc/kune/events/shared/DateUtils.java 2012-02-23 13:17:09 UTC (rev 1701)
@@ -1,26 +0,0 @@
-package cc.kune.events.shared;
-
-import java.util.Date;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-
-/**
- * The Class DateUtils try to follow RFC 2445 date-time formats.
- *
- * DTSTART;TZID=US-Eastern:19970714T133000 ;Local time and time ; zone reference
- */
-public class DateUtils {
-
- private static String RFC_DATE_TIME_FORMAT = "'DTSTART':yyyyMMdd'T'hhmmss";
- // This is not tested
- private static String RFC_DATE_TIME_FORMAT_TZ = "'DTSTART;TZID='v:yyyyMMdd'T'hhmmss";
- private static DateTimeFormat rfcDateFormat = DateTimeFormat.getFormat(RFC_DATE_TIME_FORMAT);
-
- public static Date toDate(final String date) {
- return rfcDateFormat.parse(date);
- }
-
- public static String toString(final Date date) {
- return rfcDateFormat.format(date);
- }
-}
Modified: trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java
===================================================================
--- trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java 2012-02-23 02:57:00 UTC (rev 1700)
+++ trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java 2012-02-23 13:17:09 UTC (rev 1701)
@@ -2,6 +2,7 @@
import java.util.Map;
+import cc.kune.common.client.utils.DateUtils;
import cc.kune.common.shared.res.ICalConstants;
import com.bradrydzewski.gwt.calendar.client.Appointment;
More information about the kune-commits
mailing list