<%@ page import="com.alphablox.blox.uimodel.core.*, com.alphablox.blox.uimodel.*, java.util.Calendar, java.util.Locale"%>
<%@ taglib uri="bloxtld" prefix="blox"%>
<blox:container id="dateChooserContainer">
<% BloxModel model = dateChooserContainer.getBloxModel(); ... %>
Locale locale = Locale.US;
java.util.Calendar calendar = java.util.Calendar.getInstance( locale ); ICalendar calendarAdapter = new CalendarAdapter( calendar );
java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance( java.text.DateFormat.FULL, locale ); IDateFormat dateFormatAdapter = new DateFormatAdapter( dateFormat );
<% DateChooser datechooser = DateChooser.getInstanceWithLocale( calendarAdapter, dateFormatAdapter, locale ); %>
<% ... model.add(datechooser1); %>
<%@ page contentType="text/html; charset=UTF-8" %> <%@ page import="com.alphablox.blox.uimodel.core.*, com.alphablox.blox.uimodel.*, java.util.Calendar, java.util.Locale"%> <%@ taglib uri="bloxtld" prefix="blox"%> <html> <head> <blox:header/> </head> <body> <blox:container id="dateChooserContainer"> <% BloxModel model = myContainer.getBloxModel(); Locale locale = Locale.US; java.util.Calendar calendar = java.util.Calendar.getInstance( locale ); ICalendar calendarAdapter = new CalendarAdapter( calendar ); java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance( java.text.DateFormat.FULL, locale ); IDateFormat dateFormatAdapter = new DateFormatAdapter( dateFormat ); DateChooser datechooser = DateChooser.getInstanceWithLocale( calendarAdapter, dateFormatAdapter, locale ); model.add( datechooser );%> </blox:container> </body> </html>
You can easily modify the locale to create a non-English Gregorian calendar. There are other factory methods for creating a DateChooser depending on how you want to set the locale or the initially selected date. The Specifying a selected date when the calendar is launched example demonstrates another factory method for creating a DateChooser. It is possible to have one locale for your CalendarAdapter, another for your DateFormatAdapter, and yet another for your DateChooser. For example, you can have a Japanese calendar with DateFormat (the format to use when the selected date is displayed in the text box) in a different language.
You can use either Java's Calendar or the Calendar component in the International Components for Unicode (ICU) Java™ libraries. To support multiple locales, you should use ICU because of its better support for internalization. See Creating a Gregorian calendar using ICU for multi-locale support for more information.
For a live DateChooser example, see the "DateChooser Component" example in Blox Sampler, under the UI Extensibility section.