List of usage examples for java.text DateFormat LONG
int LONG
To view the source code for java.text DateFormat LONG.
Click Source Link
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); }/*ww w .j a va2s. 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:org.nuxeo.ecm.platform.semanticentities.service.RemoteEntityServiceTest.java
@SuppressWarnings("unchecked") @Test/*from w w w. j av a 2 s .c o m*/ public void testDerefenceRemoteEntity() throws Exception { DocumentModel barackDoc = session.createDocumentModel("Person"); service.dereferenceInto(barackDoc, DBPEDIA_BARACK_OBAMA_URI, true, false); // the title and birth date are fetched from the remote entity // description assertEquals("Barack Obama", barackDoc.getTitle()); String summary = barackDoc.getProperty("entity:summary").getValue(String.class); String expectedSummary = "Barack Hussein Obama II is the 44th and current President of the United States."; assertEquals(expectedSummary, summary.substring(0, expectedSummary.length())); List<String> altnames = barackDoc.getProperty("entity:altnames").getValue(List.class); assertEquals(4, altnames.size()); // Western spelling: assertTrue(altnames.contains("Barack Obama")); // Russian spelling: assertTrue(altnames.contains("\u041e\u0431\u0430\u043c\u0430, \u0411\u0430\u0440\u0430\u043a")); Calendar birthDate = barackDoc.getProperty("person:birthDate").getValue(Calendar.class); TimeZone tz = TimeZone.getTimeZone("ECT"); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.US); formatter.setTimeZone(tz); assertEquals("August 4, 1961 1:00:00 AM CET", formatter.format(birthDate.getTime())); Blob depiction = barackDoc.getProperty("entity:depiction").getValue(Blob.class); assertNotNull(depiction); assertEquals("200px-Official_portrait_of_Barack_Obama.jpg", depiction.getFilename()); assertEquals(14748, depiction.getLength()); List<String> sameas = barackDoc.getProperty("entity:sameas").getValue(List.class); assertTrue(sameas.contains(DBPEDIA_BARACK_OBAMA_URI.toString())); // check that further dereferencing with override == false does not // erase local changes barackDoc.setPropertyValue("dc:title", "B. Obama"); barackDoc.setPropertyValue("person:birthDate", null); service.dereferenceInto(barackDoc, DBPEDIA_BARACK_OBAMA_URI, false, false); assertEquals("B. Obama", barackDoc.getTitle()); birthDate = barackDoc.getProperty("person:birthDate").getValue(Calendar.class); assertEquals("August 4, 1961 1:00:00 AM CET", formatter.format(birthDate.getTime())); // existing names are not re-added altnames = barackDoc.getProperty("entity:altnames").getValue(List.class); assertEquals(4, altnames.size()); // later dereferencing with override == true does not preserve local // changes service.dereferenceInto(barackDoc, DBPEDIA_BARACK_OBAMA_URI, true, false); assertEquals("Barack Obama", barackDoc.getTitle()); }
From source file:org.openmrs.web.WebUtil.java
public static String formatDate(Date date, Locale locale, FORMAT_TYPE type) { log.debug("Formatting date: " + date + " with locale " + locale); DateFormat dateFormat = null; if (type == FORMAT_TYPE.TIMESTAMP) { String dateTimeFormat = Context.getAdministrationService() .getGlobalPropertyValue(OpenmrsConstants.GP_SEARCH_DATE_DISPLAY_FORMAT, null); if (StringUtils.isEmpty(dateTimeFormat)) { dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); } else {// w w w. java 2 s . c om dateFormat = new OpenmrsDateFormat(new SimpleDateFormat(dateTimeFormat), locale); } } else if (type == FORMAT_TYPE.TIME) { String timeFormat = Context.getAdministrationService() .getGlobalPropertyValue(OpenmrsConstants.GP_SEARCH_DATE_DISPLAY_FORMAT, null); if (StringUtils.isEmpty(timeFormat)) { dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); } else { dateFormat = new OpenmrsDateFormat(new SimpleDateFormat(timeFormat), locale); } } else if (type == FORMAT_TYPE.DATE) { String formatValue = Context.getAdministrationService() .getGlobalPropertyValue(OpenmrsConstants.GP_SEARCH_DATE_DISPLAY_FORMAT, ""); if (StringUtils.isEmpty(formatValue)) { dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); } else { dateFormat = new OpenmrsDateFormat(new SimpleDateFormat(formatValue), locale); } } return date == null ? "" : dateFormat.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()); }// w ww. ja v a 2s .c om 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:HardcopyWriter.java
/** * The constructor for this class has a bunch of arguments: The frame argument * is required for all printing in Java. The jobname appears left justified at * the top of each printed page. The font size is specified in points, as * on-screen font sizes are. The margins are specified in inches (or fractions * of inches).//from ww w.ja va 2 s . co m */ public HardcopyWriter(Frame frame, String jobname, int fontsize, double leftmargin, double rightmargin, double topmargin, double bottommargin) throws HardcopyWriter.PrintCanceledException { // Get the PrintJob object with which we'll do all the printing. // The call is synchronized on the static printprops object, which // means that only one print dialog can be popped up at a time. // If the user clicks Cancel in the print dialog, throw an exception. Toolkit toolkit = frame.getToolkit(); // get Toolkit from Frame synchronized (printprops) { job = toolkit.getPrintJob(frame, jobname, printprops); } if (job == null) throw new PrintCanceledException("User cancelled print request"); pagesize = job.getPageDimension(); // query the page size pagedpi = job.getPageResolution(); // query the page resolution // Bug Workaround: // On windows, getPageDimension() and getPageResolution don't work, so // we've got to fake them. if (System.getProperty("os.name").regionMatches(true, 0, "windows", 0, 7)) { // Use screen dpi, which is what the PrintJob tries to emulate pagedpi = toolkit.getScreenResolution(); // Assume a 8.5" x 11" page size. A4 paper users must change this. pagesize = new Dimension((int) (8.5 * pagedpi), 11 * pagedpi); // We also have to adjust the fontsize. It is specified in points, // (1 point = 1/72 of an inch) but Windows measures it in pixels. fontsize = fontsize * pagedpi / 72; } // Compute coordinates of the upper-left corner of the page. // I.e. the coordinates of (leftmargin, topmargin). Also compute // the width and height inside of the margins. x0 = (int) (leftmargin * pagedpi); y0 = (int) (topmargin * pagedpi); width = pagesize.width - (int) ((leftmargin + rightmargin) * pagedpi); height = pagesize.height - (int) ((topmargin + bottommargin) * pagedpi); // Get body font and font size font = new Font("Monospaced", Font.PLAIN, fontsize); metrics = frame.getFontMetrics(font); lineheight = metrics.getHeight(); lineascent = metrics.getAscent(); charwidth = metrics.charWidth('0'); // Assumes a monospaced font! // Now compute columns and lines will fit inside the margins chars_per_line = width / charwidth; lines_per_page = height / lineheight; // Get header font information // And compute baseline of page header: 1/8" above the top margin headerfont = new Font("SansSerif", Font.ITALIC, fontsize); headermetrics = frame.getFontMetrics(headerfont); headery = y0 - (int) (0.125 * pagedpi) - headermetrics.getHeight() + headermetrics.getAscent(); // Compute the date/time string to display in the page header DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); df.setTimeZone(TimeZone.getDefault()); time = df.format(new Date()); this.jobname = jobname; // save name this.fontsize = fontsize; // save font size }
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 .ja v a 2 s .com*/ } 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:useraccess.ejb.RegistrationBean.java
/** * Notifies by email to the user the new registration. * @param email user's email//from w w w . j a v a 2 s .c o m * @param login future login for user * @param passwd future passwd for user */ public void notifyNewRegistration(String email, String login, String passwd) { String subject = "Registro en ECUSA"; DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); Date timeStamp = new Date(); String messageBody = "Se ha recibido su registro en ECUSA el " + dateFormatter.format(timeStamp) + ".\n" + "Su peticin ser validada y se le notificar el resultado.\n" + "Anote las siguientes credenciales para su futuro acceso a nuestra web:\n" + "Usuario (su DNI): " + login + "\n" + "Contrasea: " + passwd + "\n" + "\n Saludos."; this.mailSender.sendMail(email, subject, messageBody); }
From source file:org.apache.felix.webconsole.internal.system.VMStatPlugin.java
/** * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from ww w . ja va2 s . co m protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException { String body; if (request.getAttribute(ATTR_TERMINATED) != null) { Object restart = request.getAttribute(PARAM_SHUTDOWN_TYPE); if ((restart instanceof Boolean) && ((Boolean) restart).booleanValue()) { body = TPL_VM_RESTART; } else { body = TPL_VM_STOP; } response.getWriter().print(body); return; } body = TPL_VM_MAIN; long freeMem = Runtime.getRuntime().freeMemory() / 1024; long totalMem = Runtime.getRuntime().totalMemory() / 1024; long usedMem = totalMem - freeMem; boolean shutdownTimer = request.getParameter(PARAM_SHUTDOWN_TIMER) != null; String shutdownType = request.getParameter(PARAM_SHUTDOWN_TYPE); if (shutdownType == null) shutdownType = ""; DateFormat format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, request.getLocale()); final String startTime = format.format(new Date(startDate)); final String upTime = formatPeriod(System.currentTimeMillis() - startDate); JSONObject json = new JSONObject(); try { json.put("systemStartLevel", getStartLevel().getStartLevel()); json.put("bundleStartLevel", getStartLevel().getInitialBundleStartLevel()); json.put("lastStarted", startTime); json.put("upTime", upTime); json.put("runtime", System.getProperty("java.runtime.name") + "(build " + System.getProperty("java.runtime.version") + ")"); json.put("jvm", System.getProperty("java.vm.name") + "(build " + System.getProperty("java.vm.version") + ", " + System.getProperty("java.vm.info") + ")"); json.put("shutdownTimer", shutdownTimer); json.put("mem_total", totalMem); json.put("mem_free", freeMem); json.put("mem_used", usedMem); json.put("shutdownType", shutdownType); // only add the processors if the number is available final int processors = getAvailableProcessors(); if (processors > 0) { json.put("processors", processors); } } catch (JSONException e) { throw new IOException(e.toString()); } DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request)); vars.put("startData", json.toString()); response.getWriter().print(body); }
From source file:org.openmrs.reporting.export.DataExportFunctions.java
public DataExportFunctions() { this.patientSetService = Context.getPatientSetService(); this.patientService = Context.getPatientService(); this.conceptService = Context.getConceptService(); this.encounterService = Context.getEncounterService(); locale = Context.getLocale(); dateFormatLong = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); dateFormatShort = Context.getDateFormat(); dateFormatYmd = new SimpleDateFormat("yyyy-MM-dd", locale); }
From source file:org.jamienicol.episodes.NextEpisodeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { final int episodeIdColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_ID); episodeId = data.getInt(episodeIdColumnIndex); 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); }/* w w w . jav a 2s . co 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)); } 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 { episodeId = -1; rootView.setVisibility(View.INVISIBLE); } }