List of usage examples for org.joda.time.format DateTimeFormatter parseLocalDate
public LocalDate parseLocalDate(String text)
From source file:org.flowable.dmn.engine.impl.el.util.DateUtil.java
License:Apache License
public static Date toDate(Object dateString) { if (dateString == null) { throw new IllegalArgumentException("date string cannot be empty"); }/*from w ww .j a va2 s.c o m*/ DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd"); LocalDate dateTime = dtf.parseLocalDate((String) dateString); return dateTime.toDate(); }
From source file:org.kuali.kpme.core.calendar.entry.dao.CalendarEntryDaoOjbImpl.java
License:Educational Community License
public List<CalendarEntry> getAllCalendarEntriesForCalendarIdAndYear(String hrCalendarId, String year) { Criteria crit = new Criteria(); List<CalendarEntry> ceList = new ArrayList<CalendarEntry>(); crit.addEqualTo("hrCalendarId", hrCalendarId); DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy"); LocalDate currentYear = formatter.parseLocalDate(year); LocalDate nextYear = currentYear.plusYears(1); crit.addGreaterOrEqualThan("beginPeriodDateTime", currentYear.toDate()); crit.addLessThan("beginPeriodDateTime", nextYear.toDate()); QueryByCriteria query = new QueryByCriteria(CalendarEntry.class, crit); Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query); if (c != null) { ceList.addAll(c);//from w w w.j a v a 2s. c o m } return ceList; }
From source file:org.kuali.kpme.tklm.time.workflow.dao.TimesheetDocumentHeaderDaoOjbImpl.java
License:Educational Community License
public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) { Criteria crit = new Criteria(); List<TimesheetDocumentHeader> lstDocumentHeaders = new ArrayList<TimesheetDocumentHeader>(); crit.addEqualTo("principalId", principalId); DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy"); LocalDate currentYear = formatter.parseLocalDate(year); LocalDate nextYear = currentYear.plusYears(1); crit.addGreaterOrEqualThan("beginDate", currentYear.toDate()); crit.addLessThan("beginDate", nextYear.toDate()); QueryByCriteria query = new QueryByCriteria(TimesheetDocumentHeader.class, crit); Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query); if (c != null) { lstDocumentHeaders.addAll(c);/*from w w w.j av a 2 s . c om*/ } return lstDocumentHeaders; }
From source file:org.mifosplatform.vendoragreement.api.VendorAgreementApiResource.java
License:Mozilla Public License
@POST @Consumes({ MediaType.MULTIPART_FORM_DATA }) @Produces({ MediaType.APPLICATION_JSON }) public String createUploadFile(@HeaderParam("Content-Length") final Long fileSize, @FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition fileDetails, @FormDataParam("file") final FormDataBodyPart bodyPart, @FormDataParam("jsonData") final String jsonData) throws JSONException, IOException { FileUtils.validateFileSizeWithinPermissibleRange(fileSize, jsonData, ApiConstants.MAX_FILE_UPLOAD_SIZE_IN_MB); inputStreamObject = inputStream;//from w ww . ja v a2 s. c o m DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy"); final Date date = DateUtils.getDateOfTenant(); final DateTimeFormatter dtf = DateTimeFormat.forPattern("dd MMMM yyyy"); final LocalDate localdate = dtf.parseLocalDate(dateFormat.format(date)); JSONObject object = new JSONObject(jsonData); if (fileDetails != null) { final String fileUploadLocation = FileUtils.generateXlsFileDirectory(); final String fileName = fileDetails.getFileName(); if (!new File(fileUploadLocation).isDirectory()) { new File(fileUploadLocation).mkdirs(); } String fileLocation = null; fileLocation = FileUtils.saveToFileSystem(inputStream, fileUploadLocation, fileName); object.put("fileLocation", fileLocation); } final CommandWrapper commandRequest = new CommandWrapperBuilder() // .createVendorAgreement() // .withJson(object.toString()) // .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService .logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); }
From source file:org.mifosplatform.vendoragreement.api.VendorAgreementApiResource.java
License:Mozilla Public License
@POST @Path("{vendorAgreementId}") @Consumes({ MediaType.MULTIPART_FORM_DATA }) @Produces({ MediaType.APPLICATION_JSON }) public String updateVendorAgreement(@HeaderParam("Content-Length") final Long fileSize, @FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition fileDetails, @FormDataParam("file") final FormDataBodyPart bodyPart, @FormDataParam("jsonData") final String jsonData, @PathParam("vendorAgreementId") final Long vendorAgreementId) throws JSONException, IOException { FileUtils.validateFileSizeWithinPermissibleRange(fileSize, jsonData, ApiConstants.MAX_FILE_UPLOAD_SIZE_IN_MB); inputStreamObject = inputStream;//from w ww . j a va 2 s. co m DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy"); final Date date = DateUtils.getDateOfTenant(); final DateTimeFormatter dtf = DateTimeFormat.forPattern("dd MMMM yyyy"); final LocalDate localdate = dtf.parseLocalDate(dateFormat.format(date)); JSONObject object = new JSONObject(jsonData); if (fileDetails != null) { final String fileUploadLocation = FileUtils.generateXlsFileDirectory(); final String fileName = fileDetails.getFileName(); if (!new File(fileUploadLocation).isDirectory()) { new File(fileUploadLocation).mkdirs(); } String fileLocation = null; fileLocation = FileUtils.saveToFileSystem(inputStream, fileUploadLocation, fileName); object.put("fileLocation", fileLocation); } final CommandWrapper commandRequest = new CommandWrapperBuilder() // .updateVendorAgreement(vendorAgreementId) // .withJson(object.toString()) // .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService .logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); }
From source file:org.mpardalos.homework_plus.TaskDatabaseHelper.java
License:Open Source License
public List<Task> getTasks() { SQLiteDatabase db = getReadableDatabase(); DateTimeFormatter dbFormat = DateTimeFormat.forPattern(mContext.getString(R.string.database_date_format)); Cursor c = db.rawQuery("SELECT " + SUBJECTS_TABLE + "." + SUBJECT_NAME + "," + TASKS_TABLE + "." + TASK_DESCRIPTION + "," + TASKS_TABLE + "." + "\"_id\"" + "," + TASKS_TABLE + "." + TASK_DONE + "," + TASKS_TABLE + "." + DUE_DATE + "," + TASKS_TABLE + "." + TASK_PHOTO_LOCATION + " FROM " + TASKS_TABLE + " INNER JOIN " + SUBJECTS_TABLE + " ON (" + TASKS_TABLE + "." + "SubjectId" + "=" + SUBJECTS_TABLE + "." + "\"_id\"" + ")", null); c.moveToPosition(-1);/*from w w w . j a v a 2 s .c om*/ int subjColumn = c.getColumnIndex(SUBJECT_NAME); int descriptionColumn = c.getColumnIndex(TASK_DESCRIPTION); int idColumn = c.getColumnIndex("_id"); int dateColumn = c.getColumnIndex(DUE_DATE); int photoLocationColumn = c.getColumnIndex(TASK_PHOTO_LOCATION); List<Task> tasks = new ArrayList<>(); File photoFile; while (c.moveToNext()) { try { photoFile = new File((c.getString(photoLocationColumn))); } catch (NullPointerException e) { photoFile = null; } tasks.add(new Task(c.getString(subjColumn), c.getString(descriptionColumn), dbFormat.parseLocalDate(c.getString(dateColumn)), c.getInt(idColumn), photoFile)); } c.close(); return tasks; }
From source file:org.onebusaway.admin.json.JodaLocalDateAdapter.java
License:Apache License
@Override public LocalDate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { DateTimeFormatter fmt = DateTimeFormat.forPattern(OneBusAwayDateFormats.DATETIMEPATTERN_DATE); LocalDate result = fmt.parseLocalDate(json.getAsJsonPrimitive().getAsString()); return result; }
From source file:org.onebusaway.admin.model.BundleBuildRequest.java
License:Apache License
public LocalDate getBundleStartDate() { DateTimeFormatter dtf = ISODateTimeFormat.date(); return (_bundleStartDate == null ? null : new LocalDate(dtf.parseLocalDate(_bundleStartDate))); }
From source file:org.onebusaway.admin.model.BundleBuildRequest.java
License:Apache License
public LocalDate getBundleEndDate() { DateTimeFormatter dtf = ISODateTimeFormat.date(); return (_bundleEndDate == null ? null : new LocalDate(dtf.parseLocalDate(_bundleEndDate))); }
From source file:org.openmastery.storyweb.resources.MetricsResource.java
License:Open Source License
/** * Generate a chart with explodable (drill-downable) graphpoints, from task, to journey, to discovery cycle, to execution cycle * @param startDate inclusive beginning/*www. j a v a2s.com*/ * @param endDate exclusive end * @return SPCChart */ @GET @Path(ResourcePaths.METRICS_SPC_PATH) public SPCChart generateSPCChart(@QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate) { System.out.println("generateSPCChart [" + startDate + " : " + endDate + "]"); LocalDate jodaStartDate; LocalDate jodaEndDate; if (startDate != null && endDate != null) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd"); jodaStartDate = formatter.parseLocalDate(startDate); jodaEndDate = formatter.parseLocalDate(endDate); } else { jodaStartDate = LocalDate.now().minusDays(7); jodaEndDate = LocalDate.now(); } return metricsService.generateSPCChart(jodaStartDate, jodaEndDate); }