List of usage examples for org.joda.time.format DateTimeFormat shortDateTime
public static DateTimeFormatter shortDateTime()
From source file:net.sourceforge.atunes.kernel.modules.context.audioobject.AudioObjectBasicInfoDataSource.java
License:Open Source License
/** * Return last play date for given audio object * /* w w w . j a va2 s.c o m*/ * @param audioObject * @return */ private String getLastPlayDateData(final IAudioObject audioObject) { // Get last date played IAudioObjectStatistics stats = this.statisticsHandler.getAudioObjectStatistics(audioObject); if (stats == null) { return I18nUtils.getString("SONG_NEVER_PLAYED"); } else { DateTime date = stats.getLastPlayed(); // If date is null -> never played if (date == null) { return I18nUtils.getString("SONG_NEVER_PLAYED"); } else { return StringUtils.getString("<html>", I18nUtils.getString("LAST_DATE_PLAYED"), ":<br/><center> ", DateTimeFormat.shortDateTime().print(date), "<center></html>"); } } }
From source file:net.sourceforge.atunes.utils.DateUtils.java
License:Open Source License
/** * Returns a String with locale representation of Date, replacing / for -. * /* ww w.ja v a 2s. c om*/ * @param objDate * the obj date * * @return the string */ public static String toPathString(final DateTime objDate) { return DateTimeFormat.shortDateTime().print(objDate).replace("/", "-"); }
From source file:org.apache.isis.applib.fixturescripts.clock.ClockFixture.java
License:Apache License
private static LocalDate parseAsLocalDate(String dateStr) { for (DateTimeFormatter formatter : new DateTimeFormatter[] { DateTimeFormat.fullDateTime(), DateTimeFormat.mediumDateTime(), DateTimeFormat.shortDateTime(), DateTimeFormat.forPattern("yyyy-MM-dd"), DateTimeFormat.forPattern("yyyyMMdd"), }) { try {/*from w ww .ja va 2s.c o m*/ return formatter.parseLocalDate(dateStr); } catch (Exception e) { // continue; } } return null; }
From source file:org.apache.isis.applib.fixturescripts.clock.ClockFixture.java
License:Apache License
private static LocalDateTime parseAsLocalDateTime(String dateStr) { for (DateTimeFormatter formatter : new DateTimeFormatter[] { DateTimeFormat.fullDateTime(), DateTimeFormat.mediumDateTime(), DateTimeFormat.shortDateTime(), DateTimeFormat.forPattern("yyyyMMddhhmmss"), DateTimeFormat.forPattern("yyyyMMddhhmm") }) { try {/* w w w. ja v a2s . co m*/ return formatter.parseLocalDateTime(dateStr); } catch (Exception e) { // continue; } } return null; }
From source file:org.emonocot.harvest.media.ImageMetadataExtractorImpl.java
License:Open Source License
public ImageMetadataExtractorImpl() { dateTimeFormatters.add(ISODateTimeFormat.dateTimeParser()); dateTimeFormatters.add(DateTimeFormat.fullDate()); dateTimeFormatters.add(DateTimeFormat.fullDateTime()); dateTimeFormatters.add(DateTimeFormat.shortDate()); dateTimeFormatters.add(DateTimeFormat.shortDateTime()); dateTimeFormatters.add(DateTimeFormat.mediumDate()); dateTimeFormatters.add(DateTimeFormat.mediumDateTime()); }
From source file:org.kitodo.production.forms.MassImportForm.java
License:Open Source License
private Batch getBatch() { if (Objects.nonNull(importFile)) { List<String> arguments = new ArrayList<>(); arguments.add(FilenameUtils.getBaseName(importFile.getAbsolutePath())); arguments.add(DateTimeFormat.shortDateTime().print(new DateTime())); return new Batch(Helper.getTranslation("importedBatchLabel", arguments), BatchType.LOGISTIC); } else {//from w w w .j a v a 2 s .c om return new Batch(); } }
From source file:org.mifos.application.admin.business.service.ShutdownServiceFacadeWebTier.java
License:Open Source License
@Override public List<LoggedUserDto> getLoggedUsers(HttpServletRequest request) { ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName()); Collection<HttpSession> sessions = shutdownManager.getActiveSessions(); List<PersonnelInfo> personnelInfos = new ArrayList<PersonnelInfo>(); UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());//from ww w . j ava 2 s.c o m if (ActivityMapper.getInstance().isViewActiveSessionsPermitted(userContext, userContext.getBranchId())) { PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService(); for (HttpSession session : sessions) { UserContext userContextFromSession = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT); if (userContextFromSession == null) { continue; } PersonnelBO personnel; try { personnel = personnelBusinessService.getPersonnel(userContextFromSession.getId()); } catch (ServiceException e) { continue; } String offices = generateOfficeChain(personnel.getOffice()); String names = personnel.getPersonnelDetails().getName().getFirstName() + " " + personnel.getPersonnelDetails().getName().getLastName(); DateTimeFormatter formatter = DateTimeFormat.shortDateTime().withOffsetParsed() .withLocale(userContext.getCurrentLocale()); String activityTime = formatter.print(session.getLastAccessedTime()); ActivityContext activityContext = (ActivityContext) session .getAttribute(LoginConstants.ACTIVITYCONTEXT); String activityDesc = "[" + activityContext.getLastForward().getName() + "] " + activityContext.getLastForward().getPath(); personnelInfos.add(new PersonnelInfo(offices, names, activityTime, activityDesc)); } } Collections.sort(personnelInfos); List<LoggedUserDto> loggedUsers = new ArrayList<LoggedUserDto>(); for (PersonnelInfo personnelInfo : personnelInfos) { loggedUsers.add(new LoggedUserDto(personnelInfo.getOffices(), personnelInfo.getNames(), personnelInfo.getActivityTime(), personnelInfo.getActivityContext())); } return loggedUsers; }
From source file:org.mifos.application.admin.struts.action.ShutdownAction.java
License:Open Source License
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ShutdownActionForm shutdownForm = (ShutdownActionForm) form; if (shutdownForm.getShutdownTimeout() == null) { shutdownForm.setShutdownTimeout(DEFAULT_SHUTDOWN_TIMEOUT); }/* ww w. j a v a 2 s .c om*/ Locale locale = getUserContext(request).getCurrentLocale(); ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName()); Collection<HttpSession> sessions = shutdownManager.getActiveSessions(); List<PersonnelInfo> loggedUsers = new ArrayList<PersonnelInfo>(); PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService(); for (HttpSession session : sessions) { UserContext userContext = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT); if (userContext == null) { continue; } PersonnelBO personnel = personnelBusinessService.getPersonnel(userContext.getId()); String offices = generateOfficeChain(personnel.getOffice()); String names = personnel.getPersonnelDetails().getName().getFirstName() + " " + personnel.getPersonnelDetails().getName().getLastName(); DateTimeFormatter formatter = DateTimeFormat.shortDateTime().withOffsetParsed().withLocale(locale); String activityTime = formatter.print(session.getLastAccessedTime()); ActivityContext activityContext = (ActivityContext) session .getAttribute(LoginConstants.ACTIVITYCONTEXT); String activityDesc = "[" + activityContext.getLastForward().getName() + "] " + activityContext.getLastForward().getPath(); loggedUsers.add(new PersonnelInfo(offices, names, activityTime, activityDesc)); } Collections.sort(loggedUsers); request.setAttribute("activeSessions", loggedUsers); request.setAttribute("shutdownStatus", shutdownManager.getStatus(locale)); request.setAttribute("submitButtonDisabled", shutdownManager.isShutdownInProgress()); return mapping.findForward(ActionForwards.load_success.toString()); }
From source file:org.mifos.application.admin.system.SystemInfo.java
License:Open Source License
public String getDateTimeString() { DateTimeFormatter formatter = DateTimeFormat.shortDateTime().withOffsetParsed().withLocale(locale); return formatter.print(getDateTime().getMillis()); }
From source file:org.mifos.test.acceptance.framework.admin.SystemInfoPage.java
License:Open Source License
public void verifyDateTime(DateTime dateTime) { DateTimeFormatter formatter;//from w w w. jav a 2s . co m String expected = getDateTime(); String actual = ""; try { formatter = DateTimeFormat.shortDateTime().withLocale(Locale.getDefault()); actual = formatter.print(dateTime.getMillis()); Assert.assertEquals(expected, actual, "System date time and Mifos date time should be the same."); } catch (AssertionError e) { formatter = DateTimeFormat.shortDateTime().withLocale(Locale.US); actual = formatter.print(dateTime.getMillis()); try { Assert.assertEquals(expected, actual, "System date time and Mifos date time should be the same."); } catch (AssertionError e2) { formatter = DateTimeFormat.shortDateTime().withLocale(Locale.UK); actual = formatter.print(dateTime.getMillis()); Assert.assertEquals(expected, actual, "System date time and Mifos date time should be the same."); } } }