use of java.text.DateFormatSymbols in project Lucee by lucee.
the class DateTimeFormat method invoke.
public static String invoke(DateTime datetime, String mask, Locale locale, TimeZone tz) {
if (locale == null)
locale = Locale.US;
java.text.DateFormat format = null;
if ("short".equalsIgnoreCase(mask))
format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.SHORT, java.text.DateFormat.SHORT, locale);
else if ("medium".equalsIgnoreCase(mask))
format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM, java.text.DateFormat.MEDIUM, locale);
else if ("long".equalsIgnoreCase(mask))
format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG, locale);
else if ("full".equalsIgnoreCase(mask))
format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL, java.text.DateFormat.FULL, locale);
else if ("iso8601".equalsIgnoreCase(mask))
format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
else {
SimpleDateFormat sdf;
format = sdf = new SimpleDateFormat(convertMask(mask), locale);
if (mask != null && StringUtil.indexOfIgnoreCase(mask, "tt") == -1 && StringUtil.indexOfIgnoreCase(mask, "t") != -1) {
DateFormatSymbols dfs = new DateFormatSymbols(locale);
dfs.setAmPmStrings(AP);
sdf.setDateFormatSymbols(dfs);
}
}
format.setTimeZone(tz);
return format.format(datetime);
}
use of java.text.DateFormatSymbols in project acs-community-packaging by Alfresco.
the class DatePickerRenderer method getMonths.
private List getMonths() {
// get names of the months for default locale
Locale locale = Application.getLanguage(FacesContext.getCurrentInstance());
if (locale == null) {
locale = Locale.getDefault();
}
DateFormatSymbols dfs = new DateFormatSymbols(locale);
String[] names = dfs.getMonths();
List<SelectItem> months = new ArrayList<SelectItem>(12);
for (int i = 0; i < 12; i++) {
Integer key = Integer.valueOf(i);
months.add(new SelectItem(key, names[i]));
}
return months;
}
use of java.text.DateFormatSymbols in project processdash by dtuma.
the class TimeCardDialog method buildTopPanel.
private Component buildTopPanel() {
Box result = Box.createHorizontalBox();
result.add(new JLabel(resources.getString("Time_Card.Month_Label") + " "));
// We have to build our own month name array because the "official"
// one contains 13 month names, the last one empty for Gregorian
// Calendars
String[] monthNames = new String[12];
String[] officialMonthNames = (new DateFormatSymbols()).getMonths();
for (int i = 12; i-- > 0; ) monthNames[i] = officialMonthNames[i];
monthField = new JComboBox(monthNames);
dontGrow(monthField);
monthField.setSelectedIndex(model.getMonth() - Calendar.JANUARY);
monthField.setMaximumRowCount(12);
result.add(monthField);
monthField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
recalc();
}
});
yearField = new JTextField(5);
dontGrow(yearField);
yearField.setText(Integer.toString(model.getYear()));
result.add(yearField);
yearField.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
recalc();
}
public void removeUpdate(DocumentEvent e) {
recalc();
}
public void changedUpdate(DocumentEvent e) {
recalc();
}
});
result.add(Box.createHorizontalGlue());
result.add(new JLabel(resources.getString("Time_Format.Label") + " "));
formatType = new JComboBox();
formatType.addItem(format(75, HOURS_MINUTES));
formatType.addItem(format(75, HOURS));
formatType.addItem(format(75, MINUTES));
dontGrow(formatType);
result.add(formatType);
formatType.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
redraw();
}
});
result.add(Box.createHorizontalGlue());
hideColumns = new JCheckBox();
result.add(new JLabel(" " + resources.getString("Time_Card.Hide_Empty_Columns_Label") + " "));
result.add(hideColumns);
hideColumns.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resizeColumns();
}
});
result.add(Box.createHorizontalGlue());
JButton closeButton = new JButton(resources.getString("Close"));
dontGrow(closeButton);
result.add(Box.createVerticalStrut(closeButton.getPreferredSize().height + 4));
result.add(closeButton);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
}
});
return result;
}
use of java.text.DateFormatSymbols in project processdash by dtuma.
the class TimeLogEditor method createWeekFilterStartDaySubmenu.
private JMenuItem createWeekFilterStartDaySubmenu() {
int filterStartDay = getWeekFilterStartDay(Calendar.getInstance());
String[] dayNames = new DateFormatSymbols().getWeekdays();
JMenu submenu = new JMenu();
for (int day = 1; day <= 7; day++) submenu.add(new WeekFilterStartDayOption(submenu, dayNames, day, filterStartDay));
submenu.setFont(submenu.getFont().deriveFont(submenu.getFont().getSize2D() * 0.8f));
return submenu;
}
use of java.text.DateFormatSymbols in project opennms by OpenNMS.
the class CalendarTableBuilder method calendarTableInit.
private void calendarTableInit(int month) {
m_calTable = new CalendarTable();
m_days = new Day[42];
int dayInLastMonth;
int dayInThisMonth;
int dayInNextMonth;
int firstDayOfWeek;
String[] monthNames = new DateFormatSymbols(m_locale).getMonths();
m_calTable.setMonth(monthNames[month]);
String[] dayNames = new DateFormatSymbols(m_locale).getShortWeekdays();
DaysOfWeek titleDays = new DaysOfWeek();
int dayOfWeek;
/* SetUp Title days for calendar */
firstDayOfWeek = m_workingCalendar.getFirstDayOfWeek();
for (int i = 0; i < 7; i++) {
dayOfWeek = (firstDayOfWeek + i) < 8 ? (firstDayOfWeek + i) : 1;
titleDays.addDayName(dayNames[dayOfWeek]);
}
m_calTable.setDaysOfWeek(titleDays);
m_workingCalendar.set(Calendar.DAY_OF_MONTH, 1);
m_firstDay = m_workingCalendar.get(Calendar.DAY_OF_WEEK) - firstDayOfWeek;
if (m_firstDay < 0) {
m_firstDay += 7;
}
for (dayInLastMonth = 0; dayInLastMonth < m_firstDay; dayInLastMonth++) {
m_days[dayInLastMonth] = new Day();
m_days[dayInLastMonth].setVisible(false);
m_days[dayInLastMonth].setPctValue(0.0);
}
/**
* get the first day in the next month
*/
m_workingCalendar.add(Calendar.MONTH, 1);
Date firstDayInNextMonth = m_workingCalendar.getTime();
m_workingCalendar.add(Calendar.MONTH, -1);
Date day = m_workingCalendar.getTime();
dayInThisMonth = dayInLastMonth;
int date = 1;
while (day.before(firstDayInNextMonth)) {
m_days[dayInThisMonth] = new Day();
m_days[dayInThisMonth].setDate(date);
m_days[dayInThisMonth].setVisible(true);
m_days[dayInThisMonth].setPctValue(0.0);
dayInThisMonth++;
date++;
m_workingCalendar.add(Calendar.DATE, 1);
day = m_workingCalendar.getTime();
}
// TODO: Is the number 42 correct?
for (dayInNextMonth = dayInThisMonth; dayInNextMonth < 42; dayInNextMonth++) {
m_days[dayInNextMonth] = new Day();
m_days[dayInNextMonth].setVisible(false);
m_days[dayInNextMonth].setPctValue(0.0);
}
}
Aggregations