List of usage examples for java.text DateFormat SHORT
int SHORT
To view the source code for java.text DateFormat SHORT.
Click Source Link
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 . j a v a 2 s. c o 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:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
private static DateFormat createDateFormatter() { DateFormat formatter = null;//www . j a va2 s. c o m formatter = DateFormat.getDateInstance(DateFormat.SHORT); return formatter; }
From source file:org.apache.archiva.webdav.util.IndexWriter.java
private static String fileDateFormat(long date) { DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()); Date aDate = new Date(date); return dateFormatter.format(aDate); }
From source file:com.greenpepper.confluence.velocity.ConfluenceGreenPepper.java
public String getVersionDate() { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return df.format(GreenPepperServer.versionDate()); }
From source file:org.sakaiproject.calendar.impl.readers.IcalendarReader.java
public void importStreamFromDelimitedFile(InputStream stream, ReaderImportRowHandler handler) throws ImportException//, IOException, ParserException { try {//from ww w . j a va 2 s . c o m ColumnHeader columnDescriptionArray[] = null; String descriptionColumns[] = { "Summary", "Description", "Start Date", "Start Time", "Duration", "Location" }; int lineNumber = 1; String durationformat = ""; String requireValues = ""; // column map stuff trimLeadingTrailingQuotes(descriptionColumns); columnDescriptionArray = buildColumnDescriptionArray(descriptionColumns); // enable "relaxed parsing"; read file using LF instead of CRLF CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_OUTLOOK_COMPATIBILITY, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION, true); CalendarBuilder builder = new CalendarBuilder(); net.fortuna.ical4j.model.Calendar calendar = builder.build(stream); for (Iterator i = calendar.getComponents("VEVENT").iterator(); i.hasNext();) { Component component = (Component) i.next(); // Find event duration DateProperty dtstartdate; DateProperty dtenddate; if (component instanceof VEvent) { VEvent vEvent = (VEvent) component; dtstartdate = vEvent.getStartDate(); dtenddate = vEvent.getEndDate(true); } else { dtstartdate = (DateProperty) component.getProperty("DTSTART"); dtenddate = (DateProperty) component.getProperty("DTEND"); } if (component.getProperty("SUMMARY") == null) { M_log.warn("IcalendarReader: SUMMARY is required; event not imported"); continue; } String summary = component.getProperty("SUMMARY").getValue(); if (component.getProperty("RRULE") != null) { M_log.warn("IcalendarReader: Re-occuring events not supported: " + summary); continue; } else if (dtstartdate == null || dtenddate == null) { M_log.warn("IcalendarReader: DTSTART/DTEND required: " + summary); continue; } int durationsecs = (int) ((dtenddate.getDate().getTime() - dtstartdate.getDate().getTime()) / 1000); int durationminutes = (durationsecs / 60) % 60; int durationhours = (durationsecs / (60 * 60)) % 24; // Put duration in proper format (hh:mm or mm) if less than 1 hour if (durationminutes < 10) { durationformat = "0" + durationminutes; } else { durationformat = "" + durationminutes; } if (durationhours != 0) { durationformat = durationhours + ":" + durationformat; } String description = ""; if (component.getProperty("DESCRIPTION") != null) description = component.getProperty("DESCRIPTION").getValue(); String location = ""; if (component.getProperty("LOCATION") != null) location = component.getProperty("LOCATION").getValue(); String columns[] = { component.getProperty("SUMMARY").getValue(), description, DateFormat.getDateInstance(DateFormat.SHORT, rb.getLocale()).format(dtstartdate.getDate()), DateFormat.getTimeInstance(DateFormat.SHORT, rb.getLocale()).format(dtstartdate.getDate()), durationformat, location }; // Remove trailing/leading quotes from all columns. //trimLeadingTrailingQuotes(columns); handler.handleRow(processLine(columnDescriptionArray, lineNumber, columns)); lineNumber++; } // end for } catch (Exception e) { M_log.warn(".importSteamFromDelimitedFile(): ", e); } }
From source file:com.ehret.mixit.fragment.SessionDetailFragment.java
private void addGeneralInfo(Talk conference) { SimpleDateFormat sdf = new SimpleDateFormat("EEE"); if (conference.getStart() != null && conference.getEnd() != null) { horaire.setText(/*from ww w.j a v a2 s . c o m*/ String.format(getResources().getString(R.string.periode), sdf.format(conference.getStart()), DateFormat.getTimeInstance(DateFormat.SHORT).format(conference.getStart()), DateFormat.getTimeInstance(DateFormat.SHORT).format(conference.getEnd()))); } else { horaire.setText(getResources().getString(R.string.pasdate)); } name.setText(conference.getTitle()); if (conference.getSummary() != null) { summary.setText(Html.fromHtml(Processor.process(conference.getSummary()).trim())); } if (conference.getDescription() != null) { descriptif .setText(Html.fromHtml( Processor.process(conference.getDescription(), Configuration.builder().forceExtentedProfile().build()).trim(), null, htmlTagHandler), TextView.BufferType.SPANNABLE); } final Salle room = Salle.getSalle(conference.getRoom()); if (conference.getTrack() != null) { switch (conference.getTrack()) { case "aliens": imageTrack.setImageDrawable(getResources().getDrawable(R.drawable.mxt_icon__aliens)); track.setText("Track Alien"); break; case "design": imageTrack.setImageDrawable(getResources().getDrawable(R.drawable.mxt_icon__design)); track.setText("Track Design"); break; case "hacktivism": imageTrack.setImageDrawable(getResources().getDrawable(R.drawable.mxt_icon__hack)); track.setText("Track Hacktivism"); break; case "tech": imageTrack.setImageDrawable(getResources().getDrawable(R.drawable.mxt_icon__tech)); track.setText("Track Tech"); break; case "learn": imageTrack.setImageDrawable(getResources().getDrawable(R.drawable.mxt_icon__learn)); track.setText("Track Learn"); break; case "makers": imageTrack.setImageDrawable(getResources().getDrawable(R.drawable.mxt_icon__makers)); track.setText("Track Makers"); break; default: imageTrack.setImageDrawable(null); track.setText(""); } } if (conference.getLang() != null && "ENGLISH".equals(conference.getLang())) { langImage.setImageDrawable(getResources().getDrawable(R.drawable.en)); } else { langImage.setImageDrawable(getResources().getDrawable(R.drawable.fr)); } if (Salle.INCONNU != room) { salle.setText(String.format(getString(R.string.Salle), room.getNom())); if (room.getDrawable() != 0) { salle.setBackgroundResource(room.getDrawable()); } else { salle.setBackgroundColor(getActivity().getBaseContext().getResources().getColor(room.getColor())); } salle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Map<String, Object> parametres = new HashMap<>(); parametres.put(UIUtils.ARG_KEY_ROOM, room.getEtage()); UIUtils.startActivity(SalleActivity.class, getActivity(), parametres); } }); } }
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 ww. jav a 2s. com*/ * */ 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:useraccess.ejb.RegistrationBean.java
/** * Notifies by email to the user the new registration. * @param email user's email//from w ww. jav a 2 s. c om * @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:ch.wscr.management.ui.view.MemberView.java
/** * Die Darstellung der Daten im Grid mit Renderern anpassen * * @param grid das Grid fr die Mitgliederverwaltung *//* w ww . j a va2 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:com.androidquery.simplefeed.activity.FriendsActivity.java
@Override protected String makeTitle(long time) { String result = getString(R.string.n_friends); if (time > 0) { result += " - " + DateUtils.formatSameDayTime(time, System.currentTimeMillis(), DateFormat.SHORT, DateFormat.SHORT); }/* w w w . jav a 2 s.co m*/ return result; }