List of usage examples for org.apache.commons.lang.time DateFormatUtils format
public static String format(Date date, String pattern, Locale locale)
Formats a date/time into a specific pattern in a locale.
From source file:org.openmrs.module.lfhcforms.fragment.controller.visit.ActiveVisitStatusFragmentController.java
public void controller(FragmentConfiguration config, FragmentModel model, UiUtils ui, UiSessionContext sessionContext, @SpringBean("adtService") AdtService adtService, @SpringBean("visitHelper") VisitHelper visitHelper) { PatientDomainWrapper patient = (PatientDomainWrapper) config.getAttribute("patient"); VisitDomainWrapper activeVisit = (VisitDomainWrapper) config.getAttribute("activeVisit"); // if no activeVisit passed, retrieve activeVisit from the adtService if (activeVisit == null) { try {// w w w. java2 s . c o m Location visitLocation = adtService .getLocationThatSupportsVisits(sessionContext.getSessionLocation()); activeVisit = adtService.getActiveVisit(patient.getPatient(), visitLocation); } catch (IllegalArgumentException ex) { // location does not support visits } } model.addAttribute("activeVisitStartDatetime", null); model.addAttribute("activeVisitAttr", null); if (activeVisit != null) { model.addAttribute("activeVisit", activeVisit); model.addAttribute("activeVisitStartDatetime", DateFormatUtils.format(activeVisit.getStartDatetime(), "dd MMM yyyy hh:mm a", Context.getLocale())); // Retrieve color and short name of visit type Map<String, Object> activeVisitAttr = visitHelper.getVisitColorAndShortName(activeVisit); model.addAttribute("activeVisitAttr", activeVisitAttr); } }
From source file:org.openmrs.module.OpenmrsLite.fragment.controller.PatientHeaderFragmentController.java
public void controller(FragmentConfiguration config, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("baseIdentifierSourceService") IdentifierSourceService identifierSourceService, @FragmentParam("patient") Object patient, @InjectBeans PatientDomainWrapper wrapper, @SpringBean("adtService") AdtService adtService, UiSessionContext sessionContext, @SpringBean("featureToggles") FeatureToggleProperties featureToggleProperties) { if (patient instanceof Patient) { wrapper.setPatient((Patient) patient); config.addAttribute("patient", wrapper); }// w w w. j a v a2 s. c o m VisitDomainWrapper activeVisit = (VisitDomainWrapper) config.getAttribute("activeVisit"); if (activeVisit == null) { try { Location visitLocation = adtService .getLocationThatSupportsVisits(sessionContext.getSessionLocation()); activeVisit = adtService.getActiveVisit((Patient) patient, visitLocation); } catch (IllegalArgumentException ex) { // location does not support visits } } if (activeVisit != null) { config.addAttribute("activeVisit", activeVisit); config.addAttribute("activeVisitStartDatetime", DateFormatUtils.format(activeVisit.getStartDatetime(), "dd MMM yyyy hh:mm a", Context.getLocale())); } List<ExtraPatientIdentifierType> extraPatientIdentifierTypes = new ArrayList<ExtraPatientIdentifierType>(); for (PatientIdentifierType type : emrApiProperties.getExtraPatientIdentifierTypes()) { AutoGenerationOption option = identifierSourceService.getAutoGenerationOption(type); extraPatientIdentifierTypes.add( new ExtraPatientIdentifierType(type, option != null ? option.isManualEntryEnabled() : true)); } config.addAttribute("extraPatientIdentifierTypes", extraPatientIdentifierTypes); config.addAttribute("hideEditDemographicsButton", featureToggleProperties.isFeatureEnabled("hideEditPatientDemographicsButton")); config.addAttribute("isNewPatientHeaderEnabled", featureToggleProperties.isFeatureEnabled("enableNewPatientHeader")); }
From source file:org.openmrs.module.OpenmrsLite.fragment.controller.visit.VisitDetailsFragmentController.java
public SimpleObject getVisitDetails(@SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @SpringBean("encounterService") EncounterService encounterService, @RequestParam("visitId") Visit visit, UiUtils uiUtils, UiSessionContext sessionContext) throws ParseException { ParseEncounterToJson parseEncounterToJson = new ParseEncounterToJson(appFrameworkService, uiUtils, encounterService);/* w w w .j a v a 2 s. co m*/ SimpleObject simpleObject = SimpleObject.fromObject(visit, uiUtils, "id", "location"); User authenticatedUser = sessionContext.getCurrentUser(); boolean canDeleteVisit = authenticatedUser.hasPrivilege(EmrApiConstants.PRIVILEGE_DELETE_VISIT); Date startDatetime = visit.getStartDatetime(); Date stopDatetime = visit.getStopDatetime(); simpleObject.put("startDatetime", DateFormatUtils.format(startDatetime, "dd MMM yyyy hh:mm a", Context.getLocale())); if (stopDatetime != null) { simpleObject.put("stopDatetime", DateFormatUtils.format(stopDatetime, "dd MMM yyyy hh:mm a", Context.getLocale())); } else { simpleObject.put("stopDatetime", null); } VisitDomainWrapper visitWrapper = new VisitDomainWrapper(visit, emrApiProperties); List<SimpleObject> encounters = new ArrayList<SimpleObject>(); for (Encounter encounter : visitWrapper.getSortedEncounters()) { encounters.add(parseEncounterToJson.createEncounterJSON(authenticatedUser, encounter)); } simpleObject.put("encounters", encounters); simpleObject.put("admitted", visitWrapper.isAdmitted()); simpleObject.put("canDeleteVisit", verifyIfUserHasPermissionToDeleteVisit(visit, authenticatedUser, canDeleteVisit)); AppContextModel contextModel = sessionContext.generateAppContextModel(); contextModel.put("patientId", visit.getPatient().getPatientId()); contextModel.put("patientDead", visit.getPatient().isDead()); contextModel.put("visit", new VisitContextModel(new VisitDomainWrapper(visit, emrApiProperties))); List<Extension> visitActions = appFrameworkService .getExtensionsForCurrentUser("patientDashboard.visitActions", contextModel); Collections.sort(visitActions); simpleObject.put("availableVisitActions", convertVisitActionsToSimpleObject(visitActions)); return simpleObject; }
From source file:org.xlcloud.openstack.model.climate.json.OpenStackDateSerializer.java
@Override public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { if (value != null) { jgen.writeString(DateFormatUtils.format(value, DATE_PATTERN, DateUtils.UTC_TIME_ZONE)); }// w ww . j a va 2s . co m }
From source file:shenling.weblog.beans.atom.Feed.java
@Override public String toString() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(START_DOCUMENT); stringBuilder.append(START_FEED_ELEMENT); stringBuilder.append(START_ID_ELEMENT); stringBuilder.append(id);//from ww w . j a va2 s .c o m stringBuilder.append(END_ID_ELEMENT); stringBuilder.append(START_TITLE_ELEMENT); stringBuilder.append(title); stringBuilder.append(END_TITLE_ELEMENT); stringBuilder.append(START_SUBTITLE_ELEMENT); stringBuilder.append(subtitle); stringBuilder.append(END_SUBTITLE_ELEMENT); stringBuilder.append(START_UPDATED_ELEMENT); stringBuilder.append(DateFormatUtils.format(// using ISO-8601 instead of RFC-3339 updated, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), TimeZone.getTimeZone(TIME_ZONE_ID))); stringBuilder.append(END_UPDATED_ELEMENT); stringBuilder.append(START_AUTHOR_ELEMENT); stringBuilder.append(START_NAME_ELEMENT); stringBuilder.append(author); stringBuilder.append(END_NAME_ELEMENT); stringBuilder.append(END_AUTHOR_ELEMENT); stringBuilder.append(LINK_ELEMENT.replace(LINK_VARIABLE, link)); for (final Entry entry : entries) { stringBuilder.append(entry.toString()); } stringBuilder.append(END_FEED_ELEMENT); return stringBuilder.toString(); }
From source file:su90.etl.controller.SlaveController.java
private Result parse_imps(Iterator<String> iterator) { Result tmp = new Result(); int i = 0;// w w w . j a v a2 s . c o m // unix_timestamp,transaction_id,connection_type,device_type,count while (iterator.hasNext()) { String tmpstr = iterator.next(); switch (i) { case 0: // tmp.setIso8601_timestamp(new Timestamp(Long.parseLong(tmpstr)).toLocaleString()); tmp.setIso8601_timestamp(DateFormatUtils.format(Long.parseLong(tmpstr) * 1000, "yyyy-MM-dd'T'HH:mm:ssZZ", TimeZone.getTimeZone("America/Los_Angeles"))); break; case 1: tmp.setTransaction_id(tmpstr); break; case 2: tmp.setConnection_type(TypeParser.get(Integer.parseInt(tmpstr))); break; case 3: tmp.setDevice_type(DeviceTypeParser.get(Integer.parseInt(tmpstr))); break; case 4: tmp.setImps(Integer.parseInt(tmpstr)); break; } i++; } return tmp; }
From source file:su90.etl.controller.SlaveController.java
private Result parse_clicks(Iterator<String> iterator) { Result tmp = new Result(); int i = 0;/* w ww .ja va 2 s . com*/ // unix_timestamp,transaction_id,count while (iterator.hasNext()) { String tmpstr = iterator.next(); switch (i) { case 0: tmp.setIso8601_timestamp(DateFormatUtils.format(Long.parseLong(tmpstr) * 1000, "yyyy-MM-dd'T'HH:mm:ssZZ", TimeZone.getTimeZone("America/Los_Angeles"))); break; case 1: tmp.setTransaction_id(tmpstr); break; case 2: tmp.setClicks(Integer.parseInt(tmpstr)); break; } i++; } return tmp; }