List of usage examples for org.joda.time.format DateTimeFormat longDate
public static DateTimeFormatter longDate()
From source file:net.sourceforge.atunes.kernel.modules.context.event.EventsResultsTableCellRendererCode.java
License:Open Source License
@Override public ContextTableRowPanel<IEvent> createPanel(final JComponent superComponent, final IEvent value) { return getPanelForTableRenderer(value.getImage(), StringUtils.getString("<html>", value.getTitle(), "<br>", DateTimeFormat.longDate().print(value.getStartDate()), "<br>", value.getCity(), "<br>", value.getCountry(), "</html>"), Constants.THUMB_IMAGE_WIDTH); }
From source file:org.mayocat.shop.front.context.DateContext.java
License:Mozilla Public License
public DateContext(Date date, Locale locale) { DateTime dt = new DateTime(date); shortDate = DateTimeFormat.shortDate().withLocale(locale).print(dt); longDate = DateTimeFormat.longDate().withLocale(locale).print(dt); dayOfMonth = dt.getDayOfMonth();/* www . j av a2s.c o m*/ monthOfYear = dt.getMonthOfYear(); year = dt.getYear(); time = dt.toDate().getTime(); dateTime = dt.toString(); }
From source file:org.sakaiproject.accountvalidator.impl.jobs.CheckValidations.java
License:Educational Community License
public void execute(JobExecutionContext arg0) throws JobExecutionException { //set the user information into the current session Session sakaiSession = sessionManager.getCurrentSession(); sakaiSession.setUserId("admin"); sakaiSession.setUserEid("admin"); Calendar cal = new GregorianCalendar(); // check the old property first String maxDaysLocalStr = serverConfigurationService.getString("accountValidator.maxDays", null); if (maxDaysLocalStr == null) { log.warn("accountValidator.maxDays was found. The new property is accountValidator.maxReminderDays"); }/*from w w w . ja va 2 s. c om*/ // overwrite it with the new property if it exists, default to the old one maxDaysLocalStr = serverConfigurationService.getString("accountValidator.maxReminderDays", maxDaysLocalStr); if (maxDaysLocalStr == null) { // neither of the two properties are set, use the default maxDaysLocalStr = "" + maxDays; } try { maxDays = Integer.parseInt(maxDaysLocalStr); } catch (Exception e) { } cal.add(Calendar.DAY_OF_MONTH, (maxDays * -1)); Date maxAge = cal.getTime(); int maxAttempts = 10; String maxAttemptsStr = serverConfigurationService.getString("accountValidator.maxResendAttempts", "" + maxAttempts); try { maxAttempts = Integer.parseInt(maxAttemptsStr); } catch (Exception e) { } StringBuilder usedAccounts = new StringBuilder(); List<String> oldAccounts = new ArrayList<String>(); //we need sent and resent List<ValidationAccount> list = validationLogic.getValidationAccountsByStatus(ValidationAccount.STATUS_SENT); List<ValidationAccount> list2 = validationLogic .getValidationAccountsByStatus(ValidationAccount.STATUS_RESENT); if (list2 != null) { list.addAll(list2); } int loggedInAccounts = 0; int notLogedIn = 0; for (int i = 0; i < list.size(); i++) { ValidationAccount account = list.get(i); log.debug("account " + account.getUserId() + " created on " + account.getValidationSent()); //has the user logged in - check for a authz realm String userSiteId = siteService.getUserSiteId(account.getUserId()); if (siteService.siteExists(userSiteId)) { log.info("looks like this user logged in!"); loggedInAccounts++; if (account.getValidationsSent().intValue() < maxAttempts && serverConfigurationService.getBoolean("accountValidator.resendValidations", true)) { validationLogic.resendValidation(account.getValidationToken()); } else if (account.getValidationSent().before(maxAge) || account.getValidationsSent().intValue() >= maxAttempts) { account.setStatus(ValidationAccount.STATUS_EXPIRED); //set the received date so that it will create a new token the next time the user requests a reset cal = new GregorianCalendar(); account.setvalidationReceived(cal.getTime()); validationLogic.save(account); } else if (validationLogic.isTokenExpired(account)) { // Note: ^ isTokenExpired has the side effect of expiring tokens. We are doing this intentionally, so please do not remove this empty 'else if' block. } else { //TODO What do we do in this case? } usedAccounts.append(account.getUserId() + "\n"); } else { //user has never logged in log.debug("realm: " + "/site/~" + account.getUserId() + " does not seem to exist"); notLogedIn++; if (account.getValidationSent().before(maxAge)) { oldAccounts.add(account.getUserId()); } } } log.info("users have logged in: " + loggedInAccounts + " not logged in: " + notLogedIn); log.info("we would delete: " + oldAccounts.size() + " accounts"); if (log.isDebugEnabled()) { log.debug("users:" + usedAccounts.toString()); } //as potentially a user could have added lots of accounts we don't want to spam them Map<String, List<String>> addedMap = buildAddedMap(oldAccounts); //Ok now we have a map of each user and who they added Set<Entry<String, List<String>>> entrySet = addedMap.entrySet(); Iterator<Entry<String, List<String>>> it = entrySet.iterator(); while (it.hasNext()) { Entry<String, List<String>> entry = it.next(); String creatorId = entry.getKey(); try { User creator = userDirectoryService.getUser(creatorId); Locale locale = getUserLocale(creatorId); List<String> users = entry.getValue(); StringBuilder userText = new StringBuilder(); for (int i = 0; i < users.size(); i++) { try { User u = userDirectoryService.getUser(users.get(i)); //added the added date DateTime dt = new DateTime(u.getCreatedDate()); DateTimeFormatter fmt = DateTimeFormat.longDate(); String str = fmt.withLocale(locale).print(dt); userText.append(u.getEid() + " (" + str + ")\n"); removeCleaUpUser(u.getId()); } catch (UserNotDefinedException e) { //this is an orphaned validation token ValidationAccount va = validationLogic.getVaLidationAcountByUserId(users.get(i)); validationLogic.deleteValidationAccount(va); } } List<String> userReferences = new ArrayList<String>(); userReferences.add(creator.getReference()); Map<String, String> replacementValues = new HashMap<String, String>(); replacementValues.put("userList", userText.toString()); replacementValues.put("creatorName", creator.getDisplayName()); replacementValues.put("deleteDays", Integer.valueOf(maxDays).toString()); replacementValues.put("institution", serverConfigurationService.getString("ui.institution")); //now we send an email String fromEmail = serverConfigurationService.getString( "accountValidator.checkValidations.fromEmailAddress", serverConfigurationService.getString("mail.support")); String fromName = serverConfigurationService.getString( "accountValidator.checkValidations.fromEmailName", serverConfigurationService.getString("mail.support")); emailTemplateService.sendRenderedMessages("validate.deleted", userReferences, replacementValues, fromEmail, fromName); } catch (UserNotDefinedException e) { e.printStackTrace(); } } }
From source file:rabbit.ui.internal.viewers.DateLabelProvider.java
License:Apache License
/** * Constructor. */ public DateLabelProvider() { formatter = DateTimeFormat.longDate(); dateImage = SharedImages.CALENDAR.createImage(); }
From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeDialect.java
License:Open Source License
@Override public Set<IProcessor> getProcessors() { Set<IProcessor> processors = new HashSet<IProcessor>(); processors.add(new JodaTimeFormatProcessor("fullDate", DateTimeFormat.fullDate())); processors.add(new JodaTimeFormatProcessor("fullDateTime", DateTimeFormat.fullDateTime())); processors.add(new JodaTimeFormatProcessor("fullTime", DateTimeFormat.fullTime())); processors.add(new JodaTimeFormatProcessor("longDate", DateTimeFormat.longDate())); processors.add(new JodaTimeFormatProcessor("longDateTime", DateTimeFormat.longDateTime())); processors.add(new JodaTimeFormatProcessor("longTime", DateTimeFormat.longTime())); processors.add(new JodaTimeFormatProcessor("mediumDate", DateTimeFormat.mediumDate())); processors.add(new JodaTimeFormatProcessor("mediumDateTime", DateTimeFormat.mediumDateTime())); processors.add(new JodaTimeFormatProcessor("mediumTime", DateTimeFormat.mediumTime())); processors.add(new JodaTimeFormatProcessor("shortDate", DateTimeFormat.shortDate())); processors.add(new JodaTimeFormatProcessor("shortDateTime", DateTimeFormat.shortDateTime())); processors.add(new JodaTimeFormatProcessor("shortTime", DateTimeFormat.shortTime())); processors.add(new JodaTimeFormatProcessor("isoDateTime", ISODateTimeFormat.dateTime())); return processors; }
From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeExpressionObject.java
License:Open Source License
/** * Formats the datetime with a JodaTime long date format * * @param dateTime/*from w ww. j ava2 s . c o m*/ * The datetime * @return The formatted date */ public String longDate(DateTime dateTime) { return format(dateTime, DateTimeFormat.longDate()); }
From source file:ru.caramel.juniperbot.core.message.resolver.DateTimePlaceholderResolver.java
License:Open Source License
@Override public Object getChild(String name) { switch (name) { case "shortTime": return format(DateTimeFormat.shortTime()); case "mediumTime": return format(DateTimeFormat.mediumTime()); case "longTime": return format(DateTimeFormat.longTime()); case "fullTime": return format(DateTimeFormat.fullTime()); case "shortDate": return format(DateTimeFormat.shortDate()); case "mediumDate": return format(DateTimeFormat.mediumDate()); case "longDate": return format(DateTimeFormat.longDate()); // The same as medium case "fullDate": return format(DateTimeFormat.fullDate()); case "shortDateTime": return format(DateTimeFormat.shortDateTime()); case "mediumDateTime": return format(DateTimeFormat.mediumDateTime()); case "longDateTime": return format(DateTimeFormat.longDateTime()); case "fullDateTime": return format(DateTimeFormat.fullDateTime()); }/* w ww. ja v a 2s . c om*/ return null; }