use of java.text.DateFormatSymbols in project poi by apache.
the class TNEFDateAttribute method toString.
public String toString() {
DateFormatSymbols dfs = DateFormatSymbols.getInstance(Locale.ROOT);
DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", dfs);
df.setTimeZone(LocaleUtil.TIMEZONE_UTC);
return "Attribute " + getProperty() + ", type=" + getType() + ", date=" + df.format(data);
}
use of java.text.DateFormatSymbols in project poi by apache.
the class TestExcelStyleDateFormatter method test60369.
/**
* [Bug 60369] Month format 'MMMMM' issue with TEXT-formula and Java 8
*/
@Test
public void test60369() throws ParseException {
// Setting up the locale to be tested together with a list of asserted unicode-formatted results and put them in a map.
Locale germanLocale = Locale.GERMAN;
List<String> germanResultList = Arrays.asList("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D");
Locale russianLocale = new Locale("ru", "RU");
List<String> russianResultList = Arrays.asList("я", "ф", "м", "а", "м", "и", "и", "а", "с", "о", "н", "д");
Locale austrianLocale = new Locale("de", "AT");
List<String> austrianResultList = Arrays.asList("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D");
Locale englishLocale = Locale.UK;
List<String> englishResultList = Arrays.asList("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D");
Locale frenchLocale = Locale.FRENCH;
List<String> frenchResultList = Arrays.asList("j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d");
Locale chineseLocale = Locale.CHINESE;
List<String> chineseResultList = Arrays.asList("一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十", "十");
Locale turkishLocale = new Locale("tr", "TR");
List<String> turkishResultList = Arrays.asList("O", "Ş", "M", "N", "M", "H", "T", "A", "E", "E", "K", "A");
Locale hungarianLocale = new Locale("hu", "HU");
List<String> hungarianResultList = Arrays.asList("j", "f", "m", "á", "m", "j", "j", "a", "s", "o", "n", "d");
Locale indianLocale = new Locale("en", "IN");
List<String> indianResultList = Arrays.asList("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D");
Locale indonesianLocale = new Locale("in", "ID");
List<String> indonesianResultList = Arrays.asList("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D");
Map<Locale, List<String>> testMap = new HashMap<Locale, List<String>>();
testMap.put(germanLocale, germanResultList);
testMap.put(russianLocale, russianResultList);
testMap.put(austrianLocale, austrianResultList);
testMap.put(englishLocale, englishResultList);
testMap.put(frenchLocale, frenchResultList);
testMap.put(chineseLocale, chineseResultList);
testMap.put(turkishLocale, turkishResultList);
testMap.put(hungarianLocale, hungarianResultList);
testMap.put(indianLocale, indianResultList);
testMap.put(indonesianLocale, indonesianResultList);
// We have to set up dates as well.
SimpleDateFormat testDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
List<Date> testDates = Arrays.asList(testDateFormat.parse("12.01.1980"), testDateFormat.parse("11.02.1995"), testDateFormat.parse("10.03.2045"), testDateFormat.parse("09.04.2016"), testDateFormat.parse("08.05.2017"), testDateFormat.parse("07.06.1945"), testDateFormat.parse("06.07.1998"), testDateFormat.parse("05.08.2099"), testDateFormat.parse("04.09.1988"), testDateFormat.parse("03.10.2023"), testDateFormat.parse("02.11.1978"), testDateFormat.parse("01.12.1890"));
// Let's iterate over the test setup.
for (Locale locale : testMap.keySet()) {
//System.err.println("Locale: " + locale);
ExcelStyleDateFormatter formatter = new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT, new DateFormatSymbols(locale));
for (int i = 0; i < 12; i++) {
// Call the method to be tested!
String result = formatter.format(testDates.get(i), new StringBuffer(), new FieldPosition(java.text.DateFormat.MONTH_FIELD)).toString();
//System.err.println(result + " - " + getUnicode(result.charAt(0)));
assertEquals(getUnicode(testMap.get(locale).get(i).charAt(0)), getUnicode(result.charAt(0)));
}
}
}
use of java.text.DateFormatSymbols in project processdash by dtuma.
the class TeamMemberListTable method showCustomizationWindow.
/**
* Display a dialog window, allowing the user to customize aspects of the
* team schedule. If they click OK, apply the changes they have made.
*/
private void showCustomizationWindow() {
TeamMemberList tml = getTeamMemberList();
boolean readOnly = tml.isReadOnly() || tml.getOnlyEditableFor() != null;
int currentDOW = tml.getStartOnDayOfWeek();
JComboBox weekSelector = new JComboBox();
String selectedDayName = null;
String[] dayNames = new DateFormatSymbols().getWeekdays();
for (int i = 0; i < DAYS_OF_THE_WEEK.length; i++) {
int dow = DAYS_OF_THE_WEEK[i];
weekSelector.addItem(dayNames[dow]);
if (dow == currentDOW)
weekSelector.setSelectedItem(selectedDayName = dayNames[dow]);
}
Box wb = Box.createHorizontalBox();
wb.add(Box.createHorizontalStrut(25));
wb.add(readOnly ? new JLabel(selectedDayName) : weekSelector);
Object[] contents = new Object[] { resources.getString("Customize.Start_Day"), wb };
if (readOnly) {
JOptionPane.showMessageDialog(this, contents, //
resources.getString("Customize.Title_Read_Only"), JOptionPane.PLAIN_MESSAGE);
return;
}
JDateChooser newStartDate = new JDateChooser((Date) null);
contents = new Object[] { contents, BoxUtils.vbox(5), resources.getString("Customize.Move_Dates"), BoxUtils.hbox(25, newStartDate) };
if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(this, contents, resources.getString("Customize.Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE)) {
Object selectedDay = weekSelector.getSelectedItem();
for (int i = 0; i < dayNames.length; i++) {
if (selectedDay.equals(dayNames[i]))
tml.setStartOnDayOfWeek(i);
}
if (newStartDate.getDate() != null)
tml.moveAllStartDates(newStartDate.getDate());
updateCustomizationHyperlinkText();
getTableHeader().repaint();
}
}
use of java.text.DateFormatSymbols in project instructure-android by instructure.
the class CalendarListViewFragment method setUpListeners.
private void setUpListeners() {
final CaldroidListener listener = new CaldroidListener() {
@Override
public void onSelectDate(Date date, View view) {
// New date selected, clear out prior
mCalendarFragment.clearSelectedDates();
mRecyclerAdapter.setSelectedDay(DateTime.forInstant(date.getTime(), TimeZone.getDefault()));
if (currentCalendarView == CalendarView.DAY_VIEW) {
mCalendarFragment.setSelectedDates(date, date);
} else if (currentCalendarView == CalendarView.WEEK_VIEW) {
DateWindow dateWindow = CanvasCalendarUtils.setSelectedWeekWindow(date, mRecyclerAdapter.isStartDayMonday());
mCalendarFragment.setSelectedDates(dateWindow.getStart(), dateWindow.getEnd());
}
mCalendarFragment.refreshView();
mRecyclerAdapter.refreshListView();
}
@Override
public void onCaldroidViewCreated() {
super.onCaldroidViewCreated();
// Removing styling for upper buttons
Button leftButton = mCalendarFragment.getLeftArrowButton();
Button rightButton = mCalendarFragment.getRightArrowButton();
TextView textView = mCalendarFragment.getMonthTitleTextView();
leftButton.setVisibility(View.GONE);
rightButton.setVisibility(View.GONE);
textView.setVisibility(View.GONE);
// Initialize post view created mCalendarFragment elements
InfiniteViewPager viewPager = mCalendarFragment.getDateViewPager();
viewPager.setPageMargin((int) ViewUtils.convertDipsToPixels(32, getContext()));
if (mRecyclerAdapter.getSelectedDay() == null) {
mRecyclerAdapter.setSelectedDay(DateTime.today(TimeZone.getDefault()));
Date today = new Date(mRecyclerAdapter.getSelectedDay().getMilliseconds(TimeZone.getDefault()));
mCalendarFragment.setSelectedDates(today, today);
}
mRecyclerAdapter.setCalendarViewCreated(true);
applyTheme();
}
@Override
public void onChangeMonth(int month, int year, boolean fromCreation) {
super.onChangeMonth(month, year, fromCreation);
if (mRecyclerAdapter != null && mRecyclerAdapter.getSelectedDay() != null && month == mRecyclerAdapter.getSelectedDay().getMonth()) {
// listener. We don't want to trigger the month change logic if the month is not changing.
return;
}
if (mMonthText != null) {
if (fromCreation || hasOrientationChanged()) {
hidePanda();
return;
}
// Update Actionbar
mMonthText.setText(new DateFormatSymbols().getMonths()[month - 1] + " " + year);
}
// First time loading the calendar will trigger this, but the API calls have already been made
if (!mRecyclerAdapter.isTodayPressed() && !fromCreation) {
// Refresh for month, unless this was triggered by "today" button
mCalendarFragment.clearSelectedDates();
DateTime today = DateTime.today(TimeZone.getDefault());
if (today.getMonth() == month && today.getYear() == year) {
mRecyclerAdapter.setSelectedDay(today);
} else {
mRecyclerAdapter.setSelectedDay(new DateTime(year, month, 1, null, null, null, null));
}
mRecyclerAdapter.refreshCalendar();
}
}
};
mCalendarFragment.setCaldroidListener(listener);
}
use of java.text.DateFormatSymbols in project StreetComplete by westnordost.
the class Weekdays method getShortNames.
public static String[] getShortNames(Resources r) {
DateFormatSymbols symbols = DateFormatSymbols.getInstance();
String[] result = Arrays.copyOf(toIso8601Order(symbols.getShortWeekdays()), WEEKDAYS_VALUES);
result[PUBLIC_HOLIDAY] = r.getString(R.string.quest_openingHours_public_holidays_short);
return result;
}
Aggregations