List of usage examples for org.joda.time.format DateTimeFormatter print
public String print(ReadablePartial partial)
From source file:net.sourceforge.fenixedu.presentationTier.Action.directiveCouncil.SummariesControlAction.java
License:Open Source License
/** * Method responsible for exporting 'departmentSummaryResume' to excel file * /*from w w w . ja va2s . c om*/ * @param mapping * @param actionForm * @param request * @param response * @return * @throws IOException */ public ActionForward exportInfoToExcel(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws IOException { String departmentID = request.getParameter("departmentID"); String executionSemesterID = request.getParameter("executionSemesterID"); String categoryControl = request.getParameter("categoryControl"); final ExecutionSemester executionSemester = FenixFramework.getDomainObject(executionSemesterID); final Department department = FenixFramework.getDomainObject(departmentID); SummaryControlCategory summaryControlCategory = null; String controlCategory = null; if (!StringUtils.isEmpty(categoryControl)) { summaryControlCategory = SummaryControlCategory.valueOf(categoryControl); controlCategory = BundleUtil.getString(Bundle.ENUMERATION, summaryControlCategory.toString()); } else { controlCategory = "0-100"; } DepartmentSummaryElement departmentSummaryResume = getDepartmentSummaryResume(executionSemester, department); departmentSummaryResume.setSummaryControlCategory(summaryControlCategory); if (departmentSummaryResume != null) { String sigla = departmentSummaryResume.getDepartment().getAcronym(); DateTime dt = new DateTime(); DateTimeFormatter fmt = DateTimeFormat.forPattern("dd-MM-yyyy"); String date = fmt.print(dt); final String filename = BundleUtil.getString(Bundle.APPLICATION, "link.summaries.control") .replaceAll(" ", "_") + "_" + controlCategory + "_" + sigla + "_" + date + ".xls"; response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename=" + filename); ServletOutputStream writer = response.getOutputStream(); exportToXls(departmentSummaryResume, departmentSummaryResume.getDepartment(), executionSemester, writer); writer.flush(); response.flushBuffer(); } return null; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.pedagogicalCouncil.ViewTutorshipDA.java
License:Open Source License
private ChangeTutorshipBean initializeChangeBean(Tutorship tutorship, Partial endDate) { ExecutionYear executionYear = ExecutionYear.readByPartial(tutorship.getStartDate()); ChangeTutorshipByEntryYearBean tutorshipByEntryYearBean = new ChangeTutorshipByEntryYearBean(executionYear); tutorshipByEntryYearBean.addTutorship(tutorship); // Only one tutorship inside ChangeTutorshipBean changeTutorshipBean = tutorshipByEntryYearBean.getChangeTutorshipsBeans().iterator() .next();// w w w .ja v a 2 s . c om DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("MM/yyyy"); changeTutorshipBean.setTutorshipEndMonthYear(dateTimeFormatter.print(endDate)); return changeTutorshipBean; }
From source file:net.tourbook.device.garmin.GarminSAXHandler.java
License:Open Source License
private static void formatDT(final DateTimeFormatter jodaFormatter, final SimpleDateFormat jdkFormatter, final StringBuilder sbJdk, final StringBuilder sbJoda, final DateTime dt, final Calendar jdkCalendar) { sbJoda.append(jodaFormatter.print(dt)); sbJoda.append(" | "); //$NON-NLS-1$ jdkCalendar.setFirstDayOfWeek(Calendar.MONDAY); jdkCalendar.setMinimalDaysInFirstWeek(4); jdkCalendar.setTime(dt.toDate());// w w w . j a v a2s .c o m final int weekYear = Util.getYearForWeek(jdkCalendar); sbJdk.append(jdkFormatter.format(dt.toDate())); sbJdk.append(" " + weekYear + " | "); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:net.vexelon.currencybg.app.utils.DateTimeUtils.java
License:Open Source License
/** * * @param dateTime/* w w w . j a va 2 s . c o m*/ * @param dateFormater * @return */ public static String parseDateToString(Date dateTime, String dateFormater) { DateTime jodaTime = new DateTime(dateTime); DateTimeFormatter jodaFormater = DateTimeFormat.forPattern(dateFormater); return jodaFormater.print(jodaTime); }
From source file:nl.hyranasoftware.javagmr.domain.Game.java
@JsonIgnore public String getPrettyTimeLeft() { PrettyTime p = new PrettyTime(); p.setLocale(Locale.ENGLISH);/*w ww.ja va 2s .c om*/ if (currentTurn.getExpires() != null) { DateTimeFormatter dformat = DateTimeFormat.forPattern("dd/MM/yyyy"); return "Expires: " + p.format(currentTurn.getExpires().toDate()) + " (on " + dformat.print(currentTurn.getExpires()) + ")"; } else { DateTimeFormatter dformat = DateTimeFormat.forPattern("dd/MM/yyyy"); return "Last turn: " + p.format(currentTurn.getStarted().toDate()) + " (since " + dformat.print(currentTurn.getStarted()) + ")"; } }
From source file:nl.knaw.dans.common.solr.SolrUtil.java
License:Apache License
public static String toString(final DateTime d) { DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dUtc = d.toDateTime(DateTimeZone.UTC); return fmt.print(dUtc); }
From source file:nl.knaw.dans.dccd.oai.DCCDMetaDataService.java
License:Apache License
/** * Retrieve the XML for all the project that changed within the given dates * /*from w w w .j a v a2 s.co m*/ * @param from * @param until * @return */ public String getProjectListXML(Date from, Date until) { String url = getDccdRestUrl() + "/project"; // convert to UTC and format as ISO DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dUtc = new DateTime(from).toDateTime(DateTimeZone.UTC); String fromStr = fmt.print(dUtc); dUtc = new DateTime(until).toDateTime(DateTimeZone.UTC); String untilStr = fmt.print(dUtc); URI uri = UriBuilder.fromUri(url).queryParam("modFrom", fromStr).queryParam("modUntil", untilStr) .queryParam("limit", "1000000000") // need to specify a large number to get all results! .build(); LOG.debug("get project info with REST url: " + uri.toString()); Client client = Client.create(); WebResource resource = client.resource(uri); ClientResponse response = resource //.accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); if (Response.Status.OK.getStatusCode() != response.getStatus()) { return null; } String rStr = response.getEntity(String.class); return rStr; }
From source file:nl.knaw.dans.dccd.oai.DCCDMetaDataService.java
License:Apache License
/** * Retrieve the XML for the project that changed last * /* w w w .ja v a 2s . c o m*/ * The rest interface will return the results of a request for project * with a date restriction (from , until) sorted on the date. * And the latest one will be the first in the list of results. * So if we ask for just one project of all since the beginning, we get the one that changed last. * * @return */ private String getLastProjectXML() { String url = getDccdRestUrl() + "/project"; Date from = new Date(0); // before the archive existed // convert to UTC and format as ISO DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dUtc = new DateTime(from).toDateTime(DateTimeZone.UTC); String fromStr = fmt.print(dUtc); URI uri = UriBuilder.fromUri(url).queryParam("modFrom", fromStr).queryParam("offset", "0") .queryParam("limit", "1").build(); LOG.debug("get last project with REST url: " + uri.toString()); Client client = Client.create(); WebResource resource = client.resource(uri); ClientResponse response = resource //.accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); if (Response.Status.OK.getStatusCode() != response.getStatus()) { return null; } String rStr = response.getEntity(String.class); return rStr; }
From source file:nl.knaw.dans.dccd.rest.AbstractProjectResource.java
License:Apache License
/** * Append information anyone is allowed to see * The most important project data but not identical to TRiDaS! * /*from w ww . j av a 2s.com*/ * @param sw * writer to append to * @param dccdSB * search result */ protected void appendProjectPublicDataAsXml(java.io.StringWriter sw, DccdSB dccdSB) { // Note the Fedora pid is our sid, but sometimes called pid anyway; // confusing I know sw.append(getXMLElementString("sid", dccdSB.getPid())); // modified timestamp // convert to UTC and format as ISO DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dUtc = dccdSB.getAdministrativeStateLastChange().toDateTime(DateTimeZone.UTC); //sw.append(getXMLElementString("stateChanged", dccdSB.getAdministrativeStateLastChange().toString())); sw.append(getXMLElementString("stateChanged", fmt.print(dUtc))); // Not at first only added title, so a client can show something in a // user interface, // but now we put in (almost) everything from the search results. // title sw.append(getXMLElementString("title", dccdSB.getTridasProjectTitle())); // identifier sw.append(getXMLElementString("identifier", dccdSB.getTridasProjectIdentifier())); // category, but not std, normal etc. sw.append(getXMLElementString("category", dccdSB.getTridasProjectCategory())); // investigator sw.append(getXMLElementString("investigator", dccdSB.getTridasProjectInvestigator())); // lab(s) (combined name, address, but not concatenated...) sw.append("<laboratories>"); for (String lab : dccdSB.getTridasProjectLaboratoryCombined()) { sw.append(getXMLElementString("laboratory", lab)); } sw.append("</laboratories>"); // type(s) sw.append("<types>"); for (String type : dccdSB.getTridasProjectType()) { sw.append(getXMLElementString("type", type)); } sw.append("</types>"); // Note that this goes to another service and is a Performance Penalty sw.append(getXMLElementString("ownerOrganizationId", getOwnerOrganizationId(dccdSB))); // And this one goes to the data archive... a penalty... sw.append(getXMLElementString("language", getProjectlanguage(dccdSB))); }
From source file:nl.mpcjanssen.simpletask.AddTask.java
License:Open Source License
private void insertDateAtSelection(int dateType, DateTime date) { DateTimeFormatter formatter = ISODateTimeFormat.date(); replaceDate(dateType, formatter.print(date)); }