Search in sources :

Example 96 with DateFormatSymbols

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);
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) SimpleDateFormat(java.text.SimpleDateFormat)

Example 97 with DateFormatSymbols

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;
}
Also used : Locale(java.util.Locale) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) DateFormatSymbols(java.text.DateFormatSymbols)

Example 98 with DateFormatSymbols

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;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) DateFormatSymbols(java.text.DateFormatSymbols)

Example 99 with DateFormatSymbols

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;
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) JMenu(javax.swing.JMenu)

Example 100 with DateFormatSymbols

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);
    }
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) Date(java.util.Date)

Aggregations

DateFormatSymbols (java.text.DateFormatSymbols)144 SimpleDateFormat (java.text.SimpleDateFormat)40 Date (java.util.Date)26 ArrayList (java.util.ArrayList)25 Locale (java.util.Locale)21 Resources (android.content.res.Resources)15 View (android.view.View)14 TextView (android.widget.TextView)12 GregorianCalendar (java.util.GregorianCalendar)11 Calendar (java.util.Calendar)10 List (java.util.List)8 OnClickListener (android.view.View.OnClickListener)7 Test (org.junit.Test)7 Typeface (android.graphics.Typeface)6 RelativeLayout (android.widget.RelativeLayout)6 LayoutParams (android.app.ActionBar.LayoutParams)5 IOException (java.io.IOException)5 TypedArray (android.content.res.TypedArray)4 AdapterView (android.widget.AdapterView)4 Button (android.widget.Button)4