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:com.agilejava.docbkx.maven.AbstractTransformerMojo.java
/** * Creates an XML Processing handler for the built-in docbkx <code><?eval?></code> PI. This PI resolves maven * properties and basic math formula./* w ww. j a va2s . co m*/ * * @param resolver The initial resolver to use. * @param reader The source XML reader. * @return The XML PI filter. */ private PreprocessingFilter createPIHandler(EntityResolver resolver, XMLReader reader) { PreprocessingFilter filter = new PreprocessingFilter(reader); ProcessingInstructionHandler resolvingHandler = new ExpressionHandler(new VariableResolver() { public Object resolveVariable(String name) throws ELException { if ("date".equals(name)) { return DateFormat.getDateInstance(DateFormat.LONG).format(new Date()); } else if ("project".equals(name)) { return getMavenProject(); } else { return getMavenProject().getProperties().get(name); } } }, getLog()); filter.setHandlers(Arrays.asList(new Object[] { resolvingHandler })); filter.setEntityResolver(resolver); return filter; }
From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java
private DateFormat[] getDateFormats(Locale locale) { DateFormat dt1 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale); DateFormat dt2 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); DateFormat dt3 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); DateFormat d1 = DateFormat.getDateInstance(DateFormat.SHORT, locale); DateFormat d2 = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); DateFormat d3 = DateFormat.getDateInstance(DateFormat.LONG, locale); DateFormat rfc3399 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); DateFormat[] dfs = { dt1, dt2, dt3, rfc3399, d1, d2, d3 }; //added RFC 3339 date format (XW-473) return dfs;//w w w . j a va2s . co m }
From source file:com.alkacon.opencms.documentcenter.NewDocumentsTree.java
/** * Creates a nice localized date String from the given String.<p> * // w w w. j a v a 2s . com * @param dateLongString the date as String representation of a long value * @param localeString the current locale String * @return nice formatted date string in long mode (e.g. 15. April 2003) */ public static String getNiceDate(String dateLongString, String localeString) { Locale locale = new Locale(localeString.toLowerCase()); DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, locale); Calendar cal = new GregorianCalendar(locale); try { cal.setTimeInMillis(Long.parseLong(dateLongString)); } catch (Exception e) { //noop } return df.format(cal.getTime()); }
From source file:com.alkacon.opencms.documentcenter.NewDocumentsTree.java
/** * Creates a nice localized date String from the given day, month and year Strings.<p> * // www. j a v a2 s . c o m * @param day the number of the day as String * @param month the number of the month as String * @param year the number of the year as String * @param localeString the current locale String * @return nice formatted date string in long mode (e.g. 15. April 2003) */ public static String getNiceDate(String day, String month, String year, String localeString) { Locale locale = new Locale(localeString.toLowerCase()); DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, locale); Calendar cal = new GregorianCalendar(locale); try { cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day)); } catch (Exception e) { // noop } return df.format(cal.getTime()); }
From source file:net.wastl.webmail.xml.XMLUserData.java
private String formatDate(long date) { TimeZone tz = TimeZone.getDefault(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.DEFAULT, getPreferredLocale()); df.setTimeZone(tz);/*w w w . j av a 2 s . c o m*/ String now = df.format(new Date(date)); return now; }
From source file:com.redhat.rhn.common.localization.LocalizationService.java
/** * Format the date based on the locale and convert it to a String to * display. Uses DateFormat.SHORT. Example: 2004-12-10 13:20:00 PST * * Also includes the timezone of the current User if there is one * * @param date Date to format./*from w w w.j av a 2 s.c om*/ * @param locale Locale to use for formatting. * @return String representation of given date in given locale. */ public String formatDate(Date date, Locale locale) { // Example: 2004-12-10 13:20:00 PST StringBuilder dbuff = new StringBuilder(); DateFormat dateI = DateFormat.getDateInstance(DateFormat.SHORT, locale); dateI.setTimeZone(determineTimeZone()); DateFormat timeI = DateFormat.getTimeInstance(DateFormat.LONG, locale); timeI.setTimeZone(determineTimeZone()); dbuff.append(dateI.format(date)); dbuff.append(" "); dbuff.append(timeI.format(date)); return getDebugVersionOfString(dbuff.toString()); }
From source file:com.alkacon.opencms.registration.CmsRegistrationFormHandler.java
/** * Sends the collected data due to the configuration of the form * (email, database or both).<p>// w ww . ja va 2 s .co m * * @return true if successful */ @Override public boolean sendData() { boolean result = true; try { CmsRegistrationForm data = getRegFormConfiguration(); data.removeCaptchaField(); // fill the macro resolver for resolving in subject and content: List<I_CmsField> fields = data.getAllFields(); Iterator<I_CmsField> itFields = fields.iterator(); // add field values as macros while (itFields.hasNext()) { I_CmsField field = itFields.next(); String fValue = field.getValue(); if (field instanceof CmsDynamicField) { fValue = data.getFieldStringValueByName(field.getName()); } m_macroResolver.addMacro(field.getLabel(), fValue); if (field instanceof CmsEmailField) { if (data.isEmailAsLogin()) { m_macroResolver.addMacro(FIELD_LOGIN, fValue); } } if (!field.getLabel().equals(field.getDbLabel())) { m_macroResolver.addMacro(field.getDbLabel(), fValue); } } // add current date as macro m_macroResolver.addMacro(MACRO_DATE, CmsDateUtil.getDateTime(new Date(), DateFormat.LONG, getRequestContext().getLocale())); if (getRequestContext().currentUser().isGuestUser()) { // create the user here createUser(); } else { editUser(); } // send optional confirmation mail if (data.isConfirmationMailEnabled()) { if (!data.isConfirmationMailOptional() || Boolean.valueOf(getParameter(CmsForm.PARAM_SENDCONFIRMATION)).booleanValue()) { sendConfirmationMail(); } } if (data.isTransportEmail()) { result = sendMail(); } } catch (Exception e) { // an error occurred during mail creation if (LOG.isErrorEnabled()) { LOG.error("An unexpected error occured.", e); } getErrors().put("sendmail", e.getMessage()); result = false; } return result; }
From source file:org.exoplatform.answer.webui.FAQUtils.java
private static String getFormatDate(int dateFormat, Date myDate) { if (myDate == null) return ""; String format = (dateFormat == DateFormat.LONG) ? "EEE, MMM dd, yyyy" : "MM/dd/yyyy"; try {/* www .j a va 2 s .c o m*/ String userName = UserHelper.getCurrentUser(); if (!isFieldEmpty(userName)) { org.exoplatform.forum.service.ForumService forumService = (org.exoplatform.forum.service.ForumService) ExoContainerContext .getCurrentContainer() .getComponentInstanceOfType(org.exoplatform.forum.service.ForumService.class); org.exoplatform.forum.service.UserProfile profile = forumService.getUserSettingProfile(userName); format = (dateFormat == DateFormat.LONG) ? profile.getLongDateFormat() : profile.getShortDateFormat(); } } catch (Exception e) { log.debug("No forum settings found for date format. Will use format " + format); } format = format.replaceAll("D", "E").replace("EEE,MMM", "EEE, MMM").replace("d,y", "d, y"); return TimeConvertUtils.getFormatDate(myDate, format); }
From source file:de.uniwue.info6.webapp.lists.ExGroupTableBean.java
/** * * * @param ex/* w w w . ja va 2 s . c o m*/ * @return */ public String getLastUserEntryTime(Exercise ex) { UserEntry entry = userEntryDao.getLastUserEntry(ex); if (entry != null) { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL, new Locale("de", "DE")); return df.format(entry.getEntryTime()); } return null; }
From source file:gov.opm.scrd.batchprocessing.jobs.BatchProcessingJob.java
/** * Do execution./*from w w w. jav a 2 s . c o m*/ * * @param procMessage The process message. Used to build the mail message. * @return true if execution is successful; false to retry. * @throws BatchProcessingException If major error occurred. * @throes OPMException if there is any error during auditing */ private boolean doExecute(StringBuilder procMessage) throws BatchProcessingException, OPMException { // Reset reset(); Date now = new Date(SysTime.instance.now()); procMessage.append("Service Credit Batch started at "); procMessage.append(DateFormat.getTimeInstance(DateFormat.LONG, Locale.US).format(now)); procMessage.append(" on "); procMessage.append(DateFormat.getDateInstance(DateFormat.LONG, Locale.US).format(now)); procMessage.append(". Batch done at @#$%EndingTime%$#@."); procMessage.append(CRLF).append(CRLF); try { // Initialize the batchProcessUser List<User> list = entityManager.createQuery(JPQL_QUERY_USER_BY_USERNAME, User.class) .setParameter("username", currentUserName).getResultList(); if (list.isEmpty()) { throw new AuthorizationException("Batch process user [" + currentUserName + "] is not found"); } batchProcessUser = list.get(0); // Authorize securityService.authorize(currentUserName, Arrays.asList(new String[] { batchProcessUser.getRole().getName() }), "batchProcessingJob"); } catch (AuthorizationException e) { logger.error("User " + currentUserName + " is not allowed to run the batch service.", e); procMessage.append("User "); procMessage.append(currentUserName); procMessage.append(" is not allowed to run the batch service. "); if (batchProcessUser == null) { procMessage.append("He does not exist. "); } else { procMessage.append("He is in the ").append(batchProcessUser.getRole().getName()) .append(" group instead of the System role. "); } procMessage.append("This is a serious configuration error. Call the Program Manager or DBA. "); notifyByEmail(procMessage.toString(), "Service Credit User Violation", "ERROR"); savePaymentStatusPrint(procMessage.toString()); return false; } catch (OPMException e) { throw new BatchProcessingException("Database error authorizing batch user.", e); } catch (PersistenceException e) { throw new BatchProcessingException("Database error authorizing batch user.", e); } // Initialize today's audit batch initTodayAuditBatch(now); // Is now holiday boolean isNowHoliday = isNowHoliday(now); logger.info("Is today holiday : " + isNowHoliday); batchPhase = BatchPhase.FILE_IMPORT; // Import files if (!importFiles(now, isNowHoliday)) { savePaymentStatusPrint(procMessage.toString()); return false; } // Clean old files File toCleanDirectory = new File(directoryToClean); logger.info("Start cleaning old files in: " + toCleanDirectory); cleanOutOldFiles(toCleanDirectory); logger.info("End cleaning old files in: " + toCleanDirectory); if (!isNowHoliday) { batchPhase = BatchPhase.BILL_PROCESS; logger.info("Start Bill Processing."); boolean noMinorError = true; // Process bills try { entityManager.clear(); billProcessor.processBills(todayAuditBatch.getId(), procMessage, 0, 0, 0, 0, 0); } catch (BillProcessingException e) { throw new BatchProcessingException(e.getMessage(), e); } logger.info("End Bill Processing."); // BatchDailyAccountUpdate logger.info("Start daily account updating."); noMinorError = batchDailyAccountUpdate(procMessage) && noMinorError; logger.info("End daily account updating."); // Make GL files File glFileDirectory = new File(glDirectory); logger.info("Start making GL file: " + glFileDirectory); noMinorError = makeGLFile(glFileDirectory, procMessage, now) && noMinorError; logger.info("End making GL file: " + glFileDirectory); // Notify process email String subject = noMinorError ? "Service Credit Nightly Batch: Good" : "Service Credit Nightly Batch: Warning!"; savePaymentStatusPrint(procMessage.toString()); notifyByEmail(procMessage.toString(), subject, "BillProcessing"); } return true; }