Date, Time und DateTime
* 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-94f89814c4dfmaster
parent
f2a7fb18c6
commit
e65baec411
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue