use of java.text.DateFormatSymbols in project underlx by underlx.
the class EditNotifScheduleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
ruleId = getIntent().getStringExtra(EXTRA_RULE_ID);
} else {
ruleId = savedInstanceState.getString(STATE_RULE_ID);
}
setContentView(R.layout.activity_edit_notif_schedule);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
realm = Application.getDefaultRealmInstance(this);
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(final Realm realm) {
if (ruleId == null) {
rule = realm.createObject(NotificationRule.class, UUID.randomUUID().toString());
} else {
rule = realm.where(NotificationRule.class).equalTo("id", ruleId).findFirst();
if (rule == null) {
finish();
return;
}
}
ruleId = rule.getId();
List<Map<String, String>> data = new ArrayList<>();
weekDaysItem = new HashMap<>(3);
weekDaysItem.put("title", getString(R.string.act_edit_notif_schedule_days));
weekDaysItem.put("desc", "");
data.add(weekDaysItem);
startTimeItem = new HashMap<>(3);
startTimeItem.put("title", getString(R.string.act_edit_notif_schedule_start_time));
startTimeItem.put("desc", "");
data.add(startTimeItem);
endTimeItem = new HashMap<>(3);
endTimeItem.put("title", getString(R.string.act_edit_notif_schedule_end_time));
endTimeItem.put("desc", "");
data.add(endTimeItem);
listView = (ListView) findViewById(R.id.list_view);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(EditNotifScheduleActivity.this);
DateFormatSymbols symbols = new DateFormatSymbols();
String[] dayNames = Arrays.copyOfRange(symbols.getWeekdays(), 1, 8);
final boolean[] checkedDays = new boolean[7];
for (int day : rule.getWeekDays()) {
checkedDays[day - 1] = true;
}
builder.setMultiChoiceItems(dayNames, checkedDays, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
checkedDays[which] = isChecked;
}
});
builder.setTitle(getString(R.string.act_edit_notif_schedule_days));
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
RealmList<Integer> days = rule.getWeekDays();
days.clear();
for (int i = 0; i < 7; i++) {
if (checkedDays[i]) {
days.add(i + 1);
}
}
}
});
updateUI();
}
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
} else if (position == 1) {
RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment().setOnTimeSetListener(EditNotifScheduleActivity.this).setStartTime((int) TimeUnit.MILLISECONDS.toHours(rule.getStartTime()) % 24, (int) TimeUnit.MILLISECONDS.toMinutes(rule.getStartTime()) % 60).setDoneText(getString(android.R.string.ok)).setCancelText(getString(android.R.string.cancel)).setThemeDark();
rtpd.show(getSupportFragmentManager(), TAG_START_TIME_PICKER);
} else if (position == 2) {
RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment().setOnTimeSetListener(EditNotifScheduleActivity.this).setStartTime((int) TimeUnit.MILLISECONDS.toHours(rule.getEndTime()) % 24, (int) TimeUnit.MILLISECONDS.toMinutes(rule.getEndTime()) % 60).setDoneText(getString(android.R.string.ok)).setCancelText(getString(android.R.string.cancel)).setThemeDark();
rtpd.show(getSupportFragmentManager(), TAG_END_TIME_PICKER);
}
}
});
adapter = new SimpleAdapter(EditNotifScheduleActivity.this, data, android.R.layout.simple_list_item_2, new String[] { "title", "desc" }, new int[] { android.R.id.text1, android.R.id.text2 });
listView.setAdapter(adapter);
updateUI();
}
});
}
use of java.text.DateFormatSymbols in project evosuite by EvoSuite.
the class SimpleDateFormat method getDateFormatSymbols.
public DateFormatSymbols getDateFormatSymbols() {
Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, "getDateFormatSymbols", "()Ljava/text/DateFormatSymbols;", new Object[] {});
DateFormatSymbols ret = super.getDateFormatSymbols();
Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, ret);
return ret;
}
use of java.text.DateFormatSymbols in project BroadleafCommerce by BroadleafCommerce.
the class BLCPaymentMethodUtils method getExpirationMonthOptions.
/**
* A helper method used to construct a list of Credit Card Expiration Months
* Useful for expiration dropdown menus.
* Will use locale to determine language if a locale is available.
*
* @return List containing expiration months of the form "01 - January"
*/
public static List<String> getExpirationMonthOptions() {
DateFormatSymbols dateFormatter;
if (BroadleafRequestContext.hasLocale()) {
Locale locale = BroadleafRequestContext.getBroadleafRequestContext().getJavaLocale();
dateFormatter = new DateFormatSymbols(locale);
} else {
dateFormatter = new DateFormatSymbols();
}
List<String> expirationMonths = new ArrayList<>();
NumberFormat formatter = new DecimalFormat("00");
String[] months = dateFormatter.getMonths();
for (int i = 1; i < months.length; i++) {
expirationMonths.add(formatter.format(i) + " - " + months[i - 1]);
}
return expirationMonths;
}
use of java.text.DateFormatSymbols in project BroadleafCommerce by BroadleafCommerce.
the class FormBuilderServiceImpl method createListGrid.
/**
* Populate a ListGrid with ListGridRecords.
*
* @param className
* @param headerFields
* @param type
* @param drs
* @param sectionKey
* @param order
* @param idProperty
* @param sectionCrumbs
* @param sortPropery
* @return
*/
protected ListGrid createListGrid(String className, List<Field> headerFields, ListGrid.Type type, DynamicResultSet drs, String sectionKey, Integer order, String idProperty, List<SectionCrumb> sectionCrumbs, String sortPropery) {
// Create the list grid and set some basic attributes
ListGrid listGrid = new ListGrid();
listGrid.setClassName(className);
listGrid.getHeaderFields().addAll(headerFields);
listGrid.setListGridType(type);
listGrid.setSectionCrumbs(sectionCrumbs);
listGrid.setSectionKey(sectionKey);
listGrid.setOrder(order);
listGrid.setIdProperty(idProperty);
listGrid.setStartIndex(drs.getStartIndex());
listGrid.setTotalRecords(drs.getTotalRecords());
listGrid.setPageSize(drs.getPageSize());
String sectionIdentifier = extractSectionIdentifierFromCrumb(sectionCrumbs);
AdminSection section = navigationService.findAdminSectionByClassAndSectionId(className, sectionIdentifier);
if (section != null) {
listGrid.setExternalEntitySectionKey(section.getUrl());
}
// format date list grid cells
SimpleDateFormat formatter = new SimpleDateFormat("MMM d, Y @ hh:mma");
DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault());
symbols.setAmPmStrings(new String[] { "am", "pm" });
formatter.setDateFormatSymbols(symbols);
// that are used for the header fields.
for (Entity e : drs.getRecords()) {
ListGridRecord record = new ListGridRecord();
record.setListGrid(listGrid);
record.setDirty(e.isDirty());
record.setEntity(e);
if (StringUtils.isNotBlank(sortPropery) && e.findProperty(sortPropery) != null) {
Property sort = e.findProperty(sortPropery);
record.setDisplayOrder(sort.getValue());
}
if (e.findProperty("hasError") != null) {
Boolean hasError = Boolean.parseBoolean(e.findProperty("hasError").getValue());
record.setIsError(hasError);
if (hasError) {
ExtensionResultStatusType messageResultStatus = listGridErrorExtensionManager.getProxy().determineErrorMessageForEntity(e, record);
if (ExtensionResultStatusType.NOT_HANDLED.equals(messageResultStatus)) {
record.setErrorKey("listgrid.record.error");
}
}
}
if (e.findProperty("progressStatus") != null) {
ExtensionResultStatusType messageResultStatus = listGridErrorExtensionManager.getProxy().determineStatusMessageForEntity(e, record);
if (ExtensionResultStatusType.NOT_HANDLED.equals(messageResultStatus)) {
record.setStatus(e.findProperty("progressStatus").getValue());
record.setStatusCssClass("listgrid.record.status");
}
}
if (e.findProperty(idProperty) != null) {
record.setId(e.findProperty(idProperty).getValue());
}
for (Field headerField : headerFields) {
Property p = e.findProperty(headerField.getName());
if (p != null) {
Field recordField = new Field().withName(headerField.getName()).withFriendlyName(headerField.getFriendlyName()).withOrder(p.getMetadata().getOrder());
if (headerField instanceof ComboField) {
recordField.setValue(((ComboField) headerField).getOption(p.getValue()));
recordField.setDisplayValue(p.getDisplayValue());
} else {
if (headerField.getFieldType().equals("DATE")) {
try {
Date date = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss").parse(p.getValue());
String newValue = formatter.format(date);
recordField.setValue(newValue);
} catch (Exception ex) {
recordField.setValue(p.getValue());
}
} else {
recordField.setValue(p.getValue());
}
recordField.setDisplayValue(p.getDisplayValue());
}
recordField.setDerived(isDerivedField(headerField, recordField, p));
record.getFields().add(recordField);
}
}
if (e.findProperty(AdminMainEntity.MAIN_ENTITY_NAME_PROPERTY) != null) {
Field hiddenField = new Field().withName(AdminMainEntity.MAIN_ENTITY_NAME_PROPERTY);
hiddenField.setValue(e.findProperty(AdminMainEntity.MAIN_ENTITY_NAME_PROPERTY).getValue());
record.getHiddenFields().add(hiddenField);
}
if (e.findProperty(BasicPersistenceModule.ALTERNATE_ID_PROPERTY) != null) {
record.setAltId(e.findProperty(BasicPersistenceModule.ALTERNATE_ID_PROPERTY).getValue());
}
extensionManager.getProxy().modifyListGridRecord(className, record, e);
listGrid.getRecords().add(record);
}
if (drs.getFirstId() != null) {
listGrid.setFirstId(drs.getFirstId());
}
if (drs.getLastId() != null) {
listGrid.setLastId(drs.getLastId());
}
if (drs.getUpperCount() != null) {
listGrid.setUpperCount(drs.getUpperCount());
}
if (drs.getLowerCount() != null) {
listGrid.setLowerCount(drs.getLowerCount());
}
if (drs.getFetchType() != null) {
listGrid.setFetchType(drs.getFetchType().toString());
}
if (drs.getTotalCountLessThanPageSize() != null) {
listGrid.setTotalCountLessThanPageSize(drs.getTotalCountLessThanPageSize());
}
if (drs.getPromptSearch() != null) {
listGrid.setPromptSearch(drs.getPromptSearch());
}
return listGrid;
}
use of java.text.DateFormatSymbols in project onebusaway-application-modules by camsys.
the class ScheduleAction method getShortWeekDays.
public List<String> getShortWeekDays() {
List<String> result = new ArrayList<String>();
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(getLocale());
String[] shortWeekdays = dateFormatSymbols.getShortWeekdays();
Calendar calendar = Calendar.getInstance(getLocale());
int firstDayOfWeek = calendar.getFirstDayOfWeek();
for (int dayOfWeek = firstDayOfWeek; dayOfWeek < shortWeekdays.length; dayOfWeek++) {
result.add(shortWeekdays[dayOfWeek]);
}
for (int dayOfWeek = Calendar.SUNDAY; dayOfWeek < firstDayOfWeek; dayOfWeek++) {
result.add(shortWeekdays[dayOfWeek]);
}
return result;
}
Aggregations