List of usage examples for java.text SimpleDateFormat getCalendar
public Calendar getCalendar()
From source file:org.encuestame.mvc.controller.AbstractBaseOperations.java
/** * Get Format Date.//from w ww . j av a 2 s . com * @param date * @return */ public Date getFormatDate(final String date) { Assert.assertNotNull(date); final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DateUtil.DEFAULT_FORMAT_DATE); simpleDateFormat.format(DateUtil.DEFAULT_FORMAT_DATE); return simpleDateFormat.getCalendar().getTime(); }
From source file:org.kuali.kfs.module.bc.document.web.struts.BudgetConstructionRequestImportAction.java
/** * Imports file//from w ww . jav a 2 s. co m * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward submit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetConstructionRequestImportForm budgetConstructionImportForm = (BudgetConstructionRequestImportForm) form; BudgetRequestImportService budgetRequestImportService = SpringContext .getBean(BudgetRequestImportService.class); Integer budgetYear = budgetConstructionImportForm.getUniversityFiscalYear(); List<String> messageList = new ArrayList<String>(); SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MMM-yyyy ' ' HH:mm:ss", Locale.US); boolean isValid = validateFormData(budgetConstructionImportForm); if (!isValid) { return mapping.findForward(BCConstants.MAPPING_IMPORT_EXPORT); } Person user = GlobalVariables.getUserSession().getPerson(); String principalId = user.getPrincipalId(); Date startTime = new Date(); messageList.add("Import run started " + dateFormatter.format(startTime)); messageList.add(" "); messageList.add("Text file load phase - parsing"); List<String> parsingErrors = budgetRequestImportService.processImportFile( budgetConstructionImportForm.getFile().getInputStream(), principalId, getFieldSeparator(budgetConstructionImportForm), getTextFieldDelimiter(budgetConstructionImportForm), budgetConstructionImportForm.getFileType(), budgetYear); ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (!parsingErrors.isEmpty()) { messageList.addAll(parsingErrors); messageList.add("Import run finished at " + dateFormatter.getCalendar().getTime().toString()); budgetRequestImportService.generatePdf(messageList, baos); WebUtils.saveMimeOutputStreamAsFile(response, ReportGeneration.PDF_MIME_TYPE, baos, BCConstants.REQUEST_IMPORT_OUTPUT_FILE); return null; } messageList.add("Text file load complete"); messageList.add(" "); messageList.add("Validate data phase"); List<String> dataValidationErrorList = budgetRequestImportService.validateData(budgetYear, principalId); if (!dataValidationErrorList.isEmpty()) { messageList.add("Errors found during data validation"); messageList.addAll(dataValidationErrorList); } messageList.add("Validate data complete"); messageList.add(" "); messageList.add("Update budget phase"); List<String> updateErrorMessages = budgetRequestImportService.loadBudget(user, budgetConstructionImportForm.getFileType(), budgetYear); messageList.addAll(updateErrorMessages); messageList.add("Update budget complete"); messageList.add(" "); Date endTime = new Date(); messageList.add("Import run finished at " + dateFormatter.format(endTime)); budgetRequestImportService.generatePdf(messageList, baos); WebUtils.saveMimeOutputStreamAsFile(response, ReportGeneration.PDF_MIME_TYPE, baos, BCConstants.REQUEST_IMPORT_OUTPUT_FILE); return null; }