From e65baec411f3e2d6d864dba201a417b72afa045b Mon Sep 17 00:00:00 2001 From: quasi Date: Sat, 26 Mar 2011 19:11:20 +0000 Subject: [PATCH] Date, Time und DateTime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Korrektur für Time.java, wodurch für ein Time-Widget kein korrektes bebop-Tag erzeugt wurde * XML-Formatter für Date, Time und DateTime verwenden nun die DispatcherHelper.getNegotiatedLocale()-Methode git-svn-id: https://svn.libreccm.org/ccm/trunk@798 8810af33-2d31-482b-a856-94f89814c4df --- .../src/com/arsdigita/bebop/form/Time.java | 2 +- .../xml/formatters/DateFormatter.java | 17 ++++------- .../xml/formatters/DateTimeFormatter.java | 28 ++++++++----------- .../xml/formatters/TimeFormatter.java | 23 +++++++-------- 4 files changed, 31 insertions(+), 39 deletions(-) diff --git a/ccm-core/src/com/arsdigita/bebop/form/Time.java b/ccm-core/src/com/arsdigita/bebop/form/Time.java index ede4028e7..75ec91ed3 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/Time.java +++ b/ccm-core/src/com/arsdigita/bebop/form/Time.java @@ -250,7 +250,7 @@ public class Time extends Widget implements BebopConstants { /** The XML tag for this derived class of Widget. */ @Override protected String getElementTag() { - return "BEBOP_TIME"; + return BEBOP_TIME; } @Override diff --git a/ccm-core/src/com/arsdigita/xml/formatters/DateFormatter.java b/ccm-core/src/com/arsdigita/xml/formatters/DateFormatter.java index 3b6dd1286..79e4ba458 100755 --- a/ccm-core/src/com/arsdigita/xml/formatters/DateFormatter.java +++ b/ccm-core/src/com/arsdigita/xml/formatters/DateFormatter.java @@ -18,7 +18,7 @@ */ package com.arsdigita.xml.formatters; -import com.arsdigita.kernel.Kernel; +import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.xml.Formatter; import java.util.Locale; import java.util.Date; @@ -28,6 +28,9 @@ import java.text.DateFormat; * An alternate formatter for java.util.Date objects, * outputing the date in 'medium' format. The time * is ommitted. + * + * @author unkknown + * @author Sören Bernstein */ public class DateFormatter implements Formatter { @@ -41,20 +44,12 @@ public class DateFormatter implements Formatter { return m_config; } + @Override public String format(Object value) { Date date = (Date)value; - Locale locale; + Locale locale = DispatcherHelper.getNegotiatedLocale(); - if (getConfig().getLocale() != null) { - locale = new Locale(m_config.getLocale()); - } else { - locale = Kernel.getContext().getLocale(); - } - - if (locale == null) { - locale = Locale.ENGLISH; - } DateFormat format = DateFormat.getDateInstance (DateFormat.MEDIUM, locale); diff --git a/ccm-core/src/com/arsdigita/xml/formatters/DateTimeFormatter.java b/ccm-core/src/com/arsdigita/xml/formatters/DateTimeFormatter.java index d065122ed..f44605fa7 100755 --- a/ccm-core/src/com/arsdigita/xml/formatters/DateTimeFormatter.java +++ b/ccm-core/src/com/arsdigita/xml/formatters/DateTimeFormatter.java @@ -18,7 +18,7 @@ */ package com.arsdigita.xml.formatters; -import com.arsdigita.kernel.Kernel; +import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.xml.Formatter; import java.util.Locale; import java.util.Date; @@ -27,24 +27,20 @@ import java.text.DateFormat; /** * The default formatter for java.util.Date objects, outputing the date in * 'medium' format and the time in 'short' format. + * + * @author unknown + * @author Sören Bernstein */ public class DateTimeFormatter implements Formatter { - + + @Override public String format(Object value) { - Date date = (Date)value; - Locale locale; - DateFormatterConfig dfc = DateFormatter.getConfig(); - if (dfc.getLocale() != null) { - locale = new Locale(dfc.getLocale()); - } else { - locale = Kernel.getContext().getLocale(); - } - if (locale == null) { - locale = Locale.ENGLISH; - } - DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, - DateFormat.SHORT, locale); - + Date date = (Date) value; + Locale locale = DispatcherHelper.getNegotiatedLocale(); + + DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, + DateFormat.SHORT, locale); + return format.format(date); } } diff --git a/ccm-core/src/com/arsdigita/xml/formatters/TimeFormatter.java b/ccm-core/src/com/arsdigita/xml/formatters/TimeFormatter.java index 924aaf483..37d569ad2 100755 --- a/ccm-core/src/com/arsdigita/xml/formatters/TimeFormatter.java +++ b/ccm-core/src/com/arsdigita/xml/formatters/TimeFormatter.java @@ -18,7 +18,7 @@ */ package com.arsdigita.xml.formatters; -import com.arsdigita.kernel.Kernel; +import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.xml.Formatter; import java.util.Locale; import java.util.Date; @@ -28,19 +28,20 @@ import java.text.DateFormat; * An alternate formatter for java.util.Date objects, * outputing the date in 'medium' format. The time * is ommitted. + * + * @author unknown + * @author Sören Bernstein */ public class TimeFormatter implements Formatter { - + + @Override public String format(Object value) { - Date date = (Date)value; - - Locale locale = Kernel.getContext().getLocale(); - if (locale == null) { - locale = Locale.ENGLISH; - } - DateFormat format = DateFormat.getTimeInstance - (DateFormat.SHORT, locale); - + Date date = (Date) value; + + Locale locale = DispatcherHelper.getNegotiatedLocale(); + + DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT, locale); + return format.format(date); } }