List of usage examples for java.text DateFormat getDateInstance
public static final DateFormat getDateInstance(int style)
From source file:org.openvpms.report.AbstractExpressionEvaluator.java
/** * Returns the formatted value of an expression. * * @param expression the expression/*from w ww.j a v a2 s . com*/ * @return the result of the expression */ @Override public String getFormattedValue(String expression) { Object value = getValue(expression); if (value instanceof Date) { Date date = (Date) value; return DateFormat.getDateInstance(DateFormat.MEDIUM).format(date); } else if (value instanceof Money) { return NumberFormat.getCurrencyInstance().format(value); } else if (value instanceof BigDecimal) { DecimalFormat format = new DecimalFormat("#,##0.00;-#,##0.00"); return format.format(value); } else if (value instanceof IMObject) { return getValue((IMObject) value); } else if (value instanceof IMObjectReference) { return getValue((IMObjectReference) value); } else if (value != null) { return value.toString(); } return null; }
From source file:org.jamienicol.episodes.EpisodeDetailsFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { final int seasonNumberColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_SEASON_NUMBER); final int seasonNumber = data.getInt(seasonNumberColumnIndex); final int episodeNumberColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_EPISODE_NUMBER); final int episodeNumber = data.getInt(episodeNumberColumnIndex); final int titleColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_NAME); final String title = data.getString(titleColumnIndex); String titleText = ""; if (seasonNumber != 0) { titleText += getActivity().getString(R.string.season_episode_prefix, seasonNumber, episodeNumber); }//from w w w .ja v a2 s . c o m titleText += title; titleView.setText(titleText); final int overviewColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_OVERVIEW); if (data.isNull(overviewColumnIndex)) { overviewView.setText(""); } else { overviewView.setText(data.getString(overviewColumnIndex).trim()); } final int firstAiredColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_FIRST_AIRED); if (data.isNull(firstAiredColumnIndex)) { dateView.setText(""); } else { final Date date = new Date(data.getLong(firstAiredColumnIndex) * 1000); final String dateText = DateFormat.getDateInstance(DateFormat.LONG).format(date); dateView.setText(dateText); } final int watchedColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_WATCHED); watched = data.getInt(watchedColumnIndex) > 0 ? true : false; watchedCheckBox.setChecked(watched); rootView.setVisibility(View.VISIBLE); } else { rootView.setVisibility(View.INVISIBLE); } }
From source file:com.codeblue.service.impl.admin.AdministratorServiceImpl.java
public String dateConvert(Date date) { return DateFormat.getDateInstance(DateFormat.MEDIUM).format(date); }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CalendarEntryEditorComponent.java
public void populateFromEntry(ICalendarEntry entry) { this.startDateField.setText(DateFormat.getDateInstance(DateFormat.LONG).format(entry.getStartDate())); if (!entry.getPayload().getType().equals(PlaintextPayloadType.INSTANCE)) { throw new RuntimeException("Internal error - can only edit " + "plaintext calendar entries, this entry is of type " + entry.getPayload().getType()); }/*from w w w. ja v a 2s . c o m*/ final PlaintextPayload payload = (PlaintextPayload) entry.getPayload(); this.summaryTextField.setText(payload.getSummary()); this.notes.setText(payload.getNotes()); final Duration.Type longestDurationType = entry.getDateRange().getDuration().getLargestMatchingType(); this.durationType.setSelectedItem(longestDurationType); final long amount = Math.max(entry.getDateRange().getDuration().roundTo(longestDurationType), 1); this.durationTextField.setText("" + amount); this.reminderEnabled.setSelected(entry.isReminderEnabled()); if (entry.isReminderEnabled()) { final Type durationType = entry.getReminderOffset().getLargestMatchingType(); this.reminderOffsetType.setSelectedItem(durationType); this.reminderOffsetTextField.setText("" + entry.getReminderOffset().roundTo(durationType)); } else { this.reminderOffsetType.setSelectedItem(Duration.Type.DAYS); this.reminderOffsetTextField.setText("1"); } }
From source file:securify.ububble.securify.fragments.Payment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_payment, container, false); ButterKnife.inject(this, view); SharedPreferences settings = getActivity().getSharedPreferences("pref", 0); userId = settings.getString(Constantes.USER_ID, ""); finder = new TextFinder(getActivity()); for (int element : botones) { view.findViewById(element).setOnClickListener(this); }/* ww w . j a va 2s. c o m*/ bp = new BillingProcessor(getActivity(), LICENSEKEY, new BillingProcessor.IBillingHandler() { JSONObject json = null; @Override public void onProductPurchased(String s, TransactionDetails transactionDetails) { if (transactionDetails.productId.equals(finder.getText(OPC.ID_SUBSCRIPTION_ANNUAL))) { try { Calendar calendario = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); json = new JSONObject(transactionDetails.purchaseInfo.responseData); txtRegalaronSecurify.setText(json.getInt("purchaseTime")); RequestParams params = new RequestParams(); params.put("transaction_id", json.getString("orderId")); params.put("amount", 23.99); params.put("currency", "USD"); calendario.setTime(new Date(json.getLong("purchaseTime"))); String s_date = format.format(calendario.getTime()); calendario.add(Calendar.MONTH, 1); String e_date = format.format(calendario.getTime()); params.put("d_start", s_date); params.put("d_end", e_date); params.put("type", 2); params.put("hash", new ConvertToMD5(23.99 + userId + json.getString("orderId") + "USD" + 2 + Constantes.AMX_SECRET + e_date + s_date)); params.put("user_app_billing", contentPrincipal.userEmail); Client.post("users/" + userId + "/p", null, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { } }, getActivity()); } catch (JSONException e) { } } else if (transactionDetails.productId.equals(finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL))) { txtRegalaronSecurify.setText(transactionDetails.purchaseInfo.responseData); } else if (transactionDetails.productId.equals(finder.getText(OPC.ID_SUBSCRIPTION_TRAVELER))) { txtRegalaronSecurify.setText(transactionDetails.purchaseInfo.responseData); } } @Override public void onPurchaseHistoryRestored() { } @Override public void onBillingError(int i, Throwable throwable) { showToast("onBillingError: " + Integer.toString(i)); } @Override public void onBillingInitialized() { readyToPurchase = true; } }); Client.get("users/" + userId + "/state", null, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { userActive = response.getBoolean("user_active"); remainingDays = response.getInt("remaining_days"); Client.get("users/" + userId, null, new JsonHttpResponseHandler() { JSONObject json = null; Calendar calendario = Calendar.getInstance(); DateFormat formato = DateFormat.getDateInstance(DateFormat.FULL); @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { name = response.getString("name"); if (remainingDays < 0) { txtRegalaronSecurify.setText( String.format(finder.getText(OPC.TXT_SUSCRIPCION_CADUCADA), name)); } else if (remainingDays > 0) { String texto = remainingDays > 1 ? String.format(finder.getText(OPC.TXT_FREE_TRIALMODE_MORE), name, remainingDays + "") : String.format(finder.getText(OPC.TXT_FREE_TRIALMODE_SIMPLE), name, remainingDays + ""); txtRegalaronSecurify.setText(texto); view.findViewById(R.id.btn_pagar_anual).setOnClickListener(null); } else if (bp.isSubscribed(finder.getText(OPC.ID_SUBSCRIPTION_ANNUAL))) { json = new JSONObject(bp.getSubscriptionTransactionDetails( finder.getText(OPC.ID_SUBSCRIPTION_ANNUAL)).purchaseInfo.responseData); calendario.setTime(new Date(json.getLong("purchaseTime"))); calendario.add(Calendar.MONTH, 1); if (calendario.compareTo(Calendar.getInstance()) >= 0) { txtRegalaronSecurify .setText(String.format(finder.getText(OPC.TXT_SUSCRIPCION_CADUCAR), formato.format(calendario.getTime()))); } } else if (bp.isSubscribed(finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL))) { json = new JSONObject(bp.getSubscriptionTransactionDetails( finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL)).purchaseInfo.responseData); txtRegalaronSecurify.setText(bp.getSubscriptionTransactionDetails( finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL)).purchaseInfo.responseData); } else if (bp.isSubscribed(finder.getText(OPC.ID_SUBSCRIPTION_TRAVELER))) { json = new JSONObject(bp.getSubscriptionTransactionDetails(finder .getText(OPC.ID_SUBSCRIPTION_TRAVELER)).purchaseInfo.responseData); txtRegalaronSecurify.setText(bp.getSubscriptionTransactionDetails(finder .getText(OPC.ID_SUBSCRIPTION_TRAVELER)).purchaseInfo.responseData); } } catch (JSONException e) { } } }, getActivity()); } catch (JSONException e) { } } }, getActivity()); txtRegalaronSecurify.setVisibility(View.VISIBLE); return view; }
From source file:net.exclaimindustries.geohashdroid.activities.CentralMapExtraActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_wiki: { // Wiki time! Wiki time! It's time for wiki time! if (mInfo != null) { // Since we're in the activity version of Detailed Info, we // know we're just starting the wiki activity. Intent i = new Intent(this, WikiActivity.class); i.putExtra(WikiActivity.INFO, mInfo); startActivity(i);//from ww w .j a v a2 s. c o m } else { Toast.makeText(this, R.string.error_no_data_to_wiki, Toast.LENGTH_LONG).show(); } return true; } case R.id.action_preferences: { // We've got preferences, so we've got an Activity. Intent i = new Intent(this, PreferencesActivity.class); startActivity(i); return true; } case R.id.action_send_to_maps: { if (mInfo != null) { // To the map! Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); // Assemble the location. This is a simple latitude,longitude // setup. String location = mInfo.getLatitude() + "," + mInfo.getLongitude(); // Then, toss the location out the door and hope whatever map // we're using is paying attention. i.setData(Uri.parse("geo:0,0?q=loc:" + location + "(" + this.getString(R.string.send_to_maps_point_name, DateFormat.getDateInstance(DateFormat.LONG).format(mInfo.getCalendar().getTime())) + ")&z=15")); startActivity(i); } else { Toast.makeText(this, R.string.error_no_data_to_maps, Toast.LENGTH_LONG).show(); } return true; } case R.id.action_send_to_radar: { if (mInfo != null) { Intent i = new Intent(GHDConstants.SHOW_RADAR_ACTION); i.putExtra("latitude", (float) mInfo.getLatitude()); i.putExtra("longitude", (float) mInfo.getLongitude()); startActivity(i); } else { Toast.makeText(this, R.string.error_no_data_to_radar, Toast.LENGTH_LONG).show(); } return true; } } return false; }
From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.CalibrateListActivity.java
private void loadDetails() { TestInfo testInfo = CaddisflyApp.getApp().getCurrentTestInfo(); testInfo.setCalibrationDate(PreferencesUtil.getLong(this, testInfo.getId(), R.string.calibrationDateKey)); if (testInfo.getCalibrationDate() >= 0) { textSubtitle1.setText(//from w w w. ja va 2 s .co m DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(testInfo.getCalibrationDate()))); } testInfo.setExpiryDate(PreferencesUtil.getLong(this, testInfo.getId(), R.string.calibrationExpiryDateKey)); if (testInfo.getExpiryDate() >= 0) { textSubtitle2.setText(String.format("%s: %s", getString(R.string.expires), DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(testInfo.getExpiryDate())))); } testInfo.setBatchNumber(PreferencesUtil.getString(this, testInfo.getId(), R.string.batchNumberKey, "")); textSubtitle.setText(testInfo.getBatchNumber()); CalibrateListFragment calibrateListFragment = (CalibrateListFragment) getSupportFragmentManager() .findFragmentById(R.id.fragmentCalibrateList); if (calibrateListFragment != null) { calibrateListFragment.refresh(); } }
From source file:org.ambraproject.struts2.AmbraFreemarkerConfig.java
/** * Constructor that loads the list of css and javascript files and page titles for pages which * follow the standard templates. Creates its own composite configuration by iterating over each * of the configs in the config to assemble a union of pages defined. * @param configuration Ambra configuration * @throws Exception Exception//from w w w . j a va 2 s . c om * */ public AmbraFreemarkerConfig(Configuration configuration) throws Exception { if (log.isDebugEnabled()) { log.debug("Creating FreeMarker configuration"); } dojoDebug = configuration.getBoolean("struts.devMode"); dirPrefix = configuration.getString("ambra.platform.appContext"); subdirPrefix = configuration.getString("ambra.platform.resourceSubDir"); host = configuration.getString("ambra.platform.host"); casLoginURL = configuration.getString("ambra.services.cas.url.login"); casLogoutURL = configuration.getString("ambra.services.cas.url.logout"); registrationURL = configuration.getString("ambra.services.registration.url.registration"); changePasswordURL = configuration.getString("ambra.services.registration.url.change-password"); changeEmailURL = configuration.getString("ambra.services.registration.url.change-email"); doiResolverURL = configuration.getString("ambra.services.crossref.plos.doiurl"); pubGetURL = configuration.getString("ambra.services.pubget.url"); defaultJournalName = configuration.getString(DEFAULT_JOURNAL_NAME_CONFIG_KEY); journals = new HashMap<String, JournalConfig>(); journalsByIssn = new HashMap<String, JournalConfig>(); orgName = configuration.getString("ambra.platform.name"); feedbackEmail = configuration.getString("ambra.platform.email.feedback"); cache_storage_strong = configuration.getInt("ambra.platform.template_cache.strong", DEFAULT_TEMPLATE_CACHE_STRONG); cache_storage_soft = configuration.getInt("ambra.platform.template_cache.soft", DEFAULT_TEMPLATE_CACHE_SOFT); templateUpdateDelay = configuration.getInt("ambra.platform.template_cache.update_delay", DEFAULT_TEMPLATE_UPDATE_DELAY); String date = configuration.getString("ambra.platform.cisStartDate"); freemarkerProperties = configuration.subset("ambra.platform.freemarker"); if (date == null) { throw new Exception("Could not find the cisStartDate node in the " + "ambra platform configuration. Make sure the " + "ambra/platform/cisStartDate node exists."); } try { cisStartDate = DateFormat.getDateInstance(DateFormat.SHORT).parse(date); } catch (ParseException ex) { throw new Exception("Could not parse the cisStartDate value of \"" + date + "\" in the ambra platform configuration. Make sure the cisStartDate is in the " + "following format: dd/mm/yyyy", ex); } loadConfig(configuration); processVirtualJournalConfig(configuration); // Now that the "journals" Map exists, index that map by Eissn to populate "journalsByEissn". if (journals.entrySet() != null && journals.entrySet().size() > 0) { for (Entry<String, JournalConfig> e : journals.entrySet()) { JournalConfig j = e.getValue(); journalsByIssn.put(j.getIssn(), j); } } if (log.isTraceEnabled()) { for (Entry<String, JournalConfig> e : journals.entrySet()) { JournalConfig j = e.getValue(); log.trace("Journal: " + e.getKey()); log.trace("Journal url: " + j.getUrl()); log.trace("Default Title: " + j.getDefaultTitle()); log.trace("Default CSS: " + printArray(j.getDefaultCss())); log.trace("Default JavaScript: " + printArray(j.getDefaultCss())); Map<String, String[]> map = j.getCssFiles(); for (Entry<String, String[]> entry : map.entrySet()) { log.trace("PageName: " + entry.getKey()); log.trace("CSS FILES: " + printArray(entry.getValue())); } map = j.getJavaScriptFiles(); for (Entry<String, String[]> entry : map.entrySet()) { log.trace("PageName: " + entry.getKey()); log.trace("JS FILES: " + printArray(entry.getValue())); } for (Entry<String, String> entry : j.getTitles().entrySet()) { log.trace("PageName: " + entry.getKey()); log.trace("Title: " + entry.getValue()); } } log.trace("Dir Prefix: " + dirPrefix); log.trace("SubDir Prefix: " + subdirPrefix); log.trace("Host: " + host); log.trace("Cas url login: " + casLoginURL); log.trace("Case url logout: " + casLogoutURL); log.trace("Registration URL: " + registrationURL); log.trace("Registration Change Pass URL: " + changePasswordURL); log.trace("Registration Change EMail URL: " + changeEmailURL); log.trace("DOI Resolver URL: " + doiResolverURL); log.trace("PubGet URL:" + pubGetURL); log.trace("Default Journal Name: " + defaultJournalName); } if (log.isDebugEnabled()) { log.debug("End FreeMarker Configuration Reading"); } }
From source file:ch.wscr.management.ui.view.MemberView.java
/** * Die Darstellung der Daten im Grid mit Renderern anpassen * * @param grid das Grid fr die Mitgliederverwaltung *///from w w w . j a va 2 s . c o m private void setColumnRenderers(final Grid grid) { grid.getColumn("memberId").setRenderer(new EditDeleteButtonValueRenderer( new EditDeleteButtonValueRenderer.EditDeleteButtonClickListener() { @Override public void onEdit(ClickableRenderer.RendererClickEvent rendererClickEvent) { grid.setEditorEnabled(true); grid.editItem(rendererClickEvent.getItemId()); } @Override public void onDelete(ClickableRenderer.RendererClickEvent rendererClickEvent) { } })).setWidth(120); grid.getColumn("driverLicense").setRenderer(new BooleanRenderer()).setWidth(120); grid.getColumn("birthDate").setRenderer(new DateRenderer(DateFormat.getDateInstance(DateFormat.SHORT))) .setWidth(120); }
From source file:DateTimeEditor.java
protected void setupFormat() { switch (m_timeOrDateType) { case TIME:/*from w w w. j a v a2s. c o m*/ m_format = DateFormat.getTimeInstance(m_lengthStyle); break; case DATE: m_format = DateFormat.getDateInstance(m_lengthStyle); break; case DATETIME: m_format = DateFormat.getDateTimeInstance(m_lengthStyle, m_lengthStyle); break; } }