List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:com.money.manager.ex.adapter.AllDataAdapter.java
@SuppressWarnings({}) @Override/*ww w.j a v a 2 s . co m*/ public void bindView(View view, Context context, Cursor cursor) { // take a pointer of object UI LinearLayout linDate = (LinearLayout) view.findViewById(R.id.linearLayoutDate); TextView txtDay = (TextView) view.findViewById(R.id.textViewDay); TextView txtMonth = (TextView) view.findViewById(R.id.textViewMonth); TextView txtYear = (TextView) view.findViewById(R.id.textViewYear); TextView txtStatus = (TextView) view.findViewById(R.id.textViewStatus); TextView txtAmount = (TextView) view.findViewById(R.id.textViewAmount); TextView txtPayee = (TextView) view.findViewById(R.id.textViewPayee); TextView txtAccountName = (TextView) view.findViewById(R.id.textViewAccountName); TextView txtCategorySub = (TextView) view.findViewById(R.id.textViewCategorySub); TextView txtNotes = (TextView) view.findViewById(R.id.textViewNotes); TextView txtBalance = (TextView) view.findViewById(R.id.textViewBalance); // header index if (!mHeadersAccountIndex.containsKey(cursor.getInt(cursor.getColumnIndex(ACCOUNTID)))) { mHeadersAccountIndex.put(cursor.getInt(cursor.getColumnIndex(ACCOUNTID)), cursor.getPosition()); } // write status txtStatus.setText(mApplication.getStatusAsString(cursor.getString(cursor.getColumnIndex(STATUS)))); // color status int colorBackground = getBackgroundColorFromStatus(cursor.getString(cursor.getColumnIndex(STATUS))); linDate.setBackgroundColor(colorBackground); txtStatus.setTextColor(Color.GRAY); // date group try { Date date = new SimpleDateFormat("yyyy-MM-dd").parse(cursor.getString(cursor.getColumnIndex(DATE))); txtMonth.setText(new SimpleDateFormat("MMM").format(date)); txtYear.setText(new SimpleDateFormat("yyyy").format(date)); txtDay.setText(new SimpleDateFormat("dd").format(date)); } catch (ParseException e) { Log.e(AllDataAdapter.class.getSimpleName(), e.getMessage()); } // take transaction amount double amount = cursor.getDouble(cursor.getColumnIndex(AMOUNT)); // set currency id setCurrencyId(cursor.getInt(cursor.getColumnIndex(CURRENCYID))); // manage transfer and change amount sign if ((cursor.getString(cursor.getColumnIndex(TRANSACTIONTYPE)) != null) && (Constants.TRANSACTION_TYPE_TRANSFER .equalsIgnoreCase(cursor.getString(cursor.getColumnIndex(TRANSACTIONTYPE))))) { if (getAccountId() != cursor.getInt(cursor.getColumnIndex(TOACCOUNTID))) { amount = -(amount); // -total } else if (getAccountId() == cursor.getInt(cursor.getColumnIndex(TOACCOUNTID))) { amount = cursor.getDouble(cursor.getColumnIndex(TOTRANSAMOUNT)); // to account = account setCurrencyId(cursor.getInt(cursor.getColumnIndex(TOCURRENCYID))); } } // check amount sign CurrencyUtils currencyUtils = new CurrencyUtils(mContext); txtAmount.setText(currencyUtils.getCurrencyFormatted(getCurrencyId(), amount)); // text color amount if (Constants.TRANSACTION_TYPE_TRANSFER .equalsIgnoreCase(cursor.getString(cursor.getColumnIndex(TRANSACTIONTYPE)))) { txtAmount.setTextColor(Color.GRAY); } else if (Constants.TRANSACTION_TYPE_DEPOSIT .equalsIgnoreCase(cursor.getString(cursor.getColumnIndex(TRANSACTIONTYPE)))) { txtAmount.setTextColor(mCore.resolveColorAttribute(R.attr.holo_green_color_theme)); } else { txtAmount.setTextColor(mCore.resolveColorAttribute(R.attr.holo_red_color_theme)); } // compose payee description txtPayee.setText(cursor.getString(cursor.getColumnIndex(PAYEE))); // compose account name if (isShowAccountName()) { if (mHeadersAccountIndex.containsValue(cursor.getPosition())) { txtAccountName.setText(cursor.getString(cursor.getColumnIndex(ACCOUNTNAME))); txtAccountName.setVisibility(View.VISIBLE); } else { txtAccountName.setVisibility(View.GONE); } } else { txtAccountName.setVisibility(View.GONE); } // write ToAccountName if ((!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(TOACCOUNTNAME))))) { if (getAccountId() != cursor.getInt(cursor.getColumnIndex(TOACCOUNTID))) txtPayee.setText(cursor.getString(cursor.getColumnIndex(TOACCOUNTNAME))); else txtPayee.setText(cursor.getString(cursor.getColumnIndex(ACCOUNTNAME))); } // compose category description String categorySub = cursor.getString(cursor.getColumnIndex(CATEGORY)); // check sub category if (!(TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(SUBCATEGORY))))) { categorySub += " : <i>" + cursor.getString(cursor.getColumnIndex(SUBCATEGORY)) + "</i>"; } // write category/subcategory format html if (!TextUtils.isEmpty(categorySub)) { txtCategorySub.setText(Html.fromHtml(categorySub)); } else { txtCategorySub.setText(""); } // notes if (!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(NOTES)))) { txtNotes.setText( Html.fromHtml("<small>" + cursor.getString(cursor.getColumnIndex(NOTES)) + "</small>")); txtNotes.setVisibility(View.VISIBLE); } else { txtNotes.setVisibility(View.GONE); } // check if item is checked if (mCheckedPosition.get(cursor.getPosition(), false)) { view.setBackgroundResource(R.color.holo_blue_light); } else { view.setBackgroundResource(android.R.color.transparent); } // balance account or days left if (mTypeCursor == TypeCursor.ALLDATA) { if (isShowBalanceAmount() && getDatabase() != null) { int transId = cursor.getInt(cursor.getColumnIndex(ID)); // create thread for calculate balance amount BalanceAmount balanceAmount = new BalanceAmount(); balanceAmount.setAccountId(getAccountId()); balanceAmount.setDate(cursor.getString(cursor.getColumnIndex(DATE))); balanceAmount.setTextView(txtBalance); balanceAmount.setContext(mContext); balanceAmount.setDatabase(getDatabase()); balanceAmount.setTransId(transId); // execute thread balanceAmount.execute(); } else { txtBalance.setVisibility(View.GONE); } } else { int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT)); if (daysLeft == 0) { txtBalance.setText(R.string.inactive); } else { txtBalance.setText(Integer.toString(Math.abs(daysLeft)) + " " + context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue)); } txtBalance.setVisibility(View.VISIBLE); } }
From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java
public Date getSampleDateTime() { SimpleDateFormat sampleDateFormat = new SimpleDateFormat("yyyyDDDHHmmss"); Date sampleDateTime = new Date(0L); // get hours/minutes/seconds from the decimal hours time field double decimalHour = new Double(getSampleTime()).doubleValue(); int wholeHour = new Double(decimalHour).intValue(); double fraction = decimalHour - wholeHour; int minutes = new Double(fraction * 60d).intValue(); double secondsFraction = (fraction * 60d) - minutes; int seconds = new Double(Math.round((secondsFraction * 60d))).intValue(); // create a string version of the date String dateString = getSampleDate(); dateString += new Integer(wholeHour).toString(); dateString += new Integer(minutes).toString(); dateString += new Integer(seconds).toString(); // convert to a Java Date (instrument time is UTC) try {// w ww . ja va2 s. c o m sampleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); sampleDateTime = sampleDateFormat.parse(dateString); } catch (ParseException pe) { logger.debug("There was a problem parsing the sampleDateTime. The error " + "message was: " + pe.getMessage()); } return sampleDateTime; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.scientificCouncil.credits.ViewTeacherCreditsReportDispatchAction.java
public ActionForward exportGlobalToExcel(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws FenixServiceException, InvalidPeriodException, ParseException { final String fromExecutionYearID = request.getParameter("fromExecutionYearID"); final String untilExecutionYearID = request.getParameter("untilExecutionYearID"); final String departmentID = request.getParameter("departmentID"); final ExecutionYear beginExecutionYear = FenixFramework.getDomainObject(fromExecutionYearID); final ExecutionYear endExecutionYear = FenixFramework.getDomainObject(untilExecutionYearID); final ExecutionSemester beginExecutionSemester; final ExecutionSemester endExecutionSemester = endExecutionYear.getExecutionSemesterFor(2); if (beginExecutionYear.getPreviousExecutionYear() .equals(ExecutionSemester.readStartExecutionSemesterForCredits().getExecutionYear())) { beginExecutionSemester = ExecutionSemester.readStartExecutionSemesterForCredits(); } else {/*ww w. j a v a 2 s .c o m*/ beginExecutionSemester = beginExecutionYear.getPreviousExecutionYear().getExecutionSemesterFor(1); } Set<Department> departments = new TreeSet<Department>(Department.COMPARATOR_BY_NAME); if (departmentID == null) { departments.addAll(rootDomainObject.getDepartmentsSet()); } else { departments.add(FenixFramework.<Department>getDomainObject(departmentID)); } SheetData<Department> data = new SheetData<Department>(departments) { @Override protected void makeLine(Department department) { addCell("Departamento", department.getRealName(), "Total"); Map<ExecutionYear, PeriodCreditsReportDTO> departmentPeriodTotalCredits = null; try { departmentPeriodTotalCredits = ReadDepartmentTotalCreditsByPeriod .run(department.getDepartmentUnit(), beginExecutionSemester, endExecutionSemester); } catch (ParseException e) { logger.error(e.getMessage(), e); } ExecutionYear lastExecutionYear = null; for (ExecutionYear executionYear = beginExecutionSemester.getExecutionYear(); executionYear != null && executionYear.isBeforeOrEquals(endExecutionYear); executionYear = executionYear .getNextExecutionYear()) { PeriodCreditsReportDTO periodCreditsReportDTO = departmentPeriodTotalCredits.get(executionYear); addCell(executionYear.getYear(), (short) 3, "Docentes Carreira", (short) 1, periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getCareerCategoryTeacherCredits(), (short) 1, Formula.SUM_FOOTER, (short) 1); addCell("Restantes Categorias", periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getNotCareerCategoryTeacherCredits(), Formula.SUM_FOOTER); addCell("Saldo Final", periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getCredits(), Formula.SUM_FOOTER); lastExecutionYear = executionYear; } if (lastExecutionYear != null) { PeriodCreditsReportDTO periodCreditsReportDTO = departmentPeriodTotalCredits .get(lastExecutionYear); addCell("N Docentes " + lastExecutionYear.getYear(), (short) 3, "Docentes Carreira", (short) 1, periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getCareerTeachersSize(), (short) 1, Formula.SUM_FOOTER, (short) 1); addCell("Restantes Categorias", periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getNotCareerTeachersSize(), Formula.SUM_FOOTER); addCell("Saldo Final", periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getTeachersSize(), Formula.SUM_FOOTER); addCell("Saldo per capita " + lastExecutionYear.getYear(), (short) 3, "Docentes Carreira", (short) 1, periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getCareerTeachersBalance(), (short) 1, Formula.SUM_FOOTER, (short) 1); addCell("Restantes Categorias", periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getNotCareerTeachersBalance(), Formula.SUM_FOOTER); addCell("Saldo Final", periodCreditsReportDTO == null ? null : periodCreditsReportDTO.getBalance(), Formula.SUM_FOOTER); } } }; try { String filename = "RelatorioCreditos:" + getFileName(Calendar.getInstance().getTime()); final ServletOutputStream writer = response.getOutputStream(); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename=" + filename + ".xls"); new SpreadsheetBuilder().addSheet("RelatorioCreditos", data).build(WorkbookExportFormat.EXCEL, writer); writer.flush(); response.flushBuffer(); } catch (IOException e) { throw new FenixServiceException(); } return null; }
From source file:com.microsoft.tfs.client.common.ui.controls.generic.DatepickerCombo.java
/** * Gets the Date value held in this control. If this method returns null, * the caller may need to call isValid() to determine whether the null value * indicates that an unparsable value was entered by the user. * * @return the Date value described above *//* w w w. j a v a 2 s . co m*/ public Date getDate() { final boolean needToParse = (dateValue == null && valid == null); if (needToParse) { valid = Boolean.TRUE; final String valueToParse = textValue.trim(); if (valueToParse.length() > 0) { try { final Calendar parsedCal = lenientDateTimeParser.parse(valueToParse, true, true); if (parsedCal != null) { dateValue = parsedCal.getTime(); if (log.isDebugEnabled()) { log.debug( MessageFormat.format("getDate(), parsed [{0}] to [{1}]", textValue, dateValue)); //$NON-NLS-1$ } } } catch (final ParseException e) { valid = Boolean.FALSE; if (log.isDebugEnabled()) { log.debug(MessageFormat.format("getDate(), couldn''t parse [{0}] ({1})", //$NON-NLS-1$ textValue, e.getMessage())); } } } else { if (log.isDebugEnabled()) { log.debug("getDate(), value to parse was empty or whitespace"); //$NON-NLS-1$ } } } return dateValue; }
From source file:org.egov.egf.web.actions.contra.ContraBTCAction.java
private List<Map<String, Object>> createInstruments(final ContraBean cBean) { final Map<String, Object> iMap = new HashMap<String, Object>(); final List<Map<String, Object>> iList = new ArrayList<Map<String, Object>>(); if (!showChequeNumber()) { final Bankaccount bankAccount = getBank(Integer.valueOf(contraBean.getAccountNumberId())); cBean.setChequeNumber(chequeService.nextChequeNumber(bankAccount.getId().toString(), 1, getVouchermis().getDepartmentid().getId().intValue())); }/* w w w .jav a2 s . c o m*/ iMap.put("Instrument number", cBean.getChequeNumber()); Date dt = null; try { dt = Constants.DDMMYYYYFORMAT2.parse(contraBean.getChequeDate()); } catch (final ParseException e) { LOGGER.error("Parse Error" + e.getMessage(), e); throw new ApplicationRuntimeException(e.getMessage()); } iMap.put("Instrument date", dt); iMap.put("Instrument amount", Double.valueOf(cBean.getAmount().toString())); iMap.put("Instrument type", FinancialConstants.INSTRUMENT_TYPE_CHEQUE); final Bankaccount bankAccount = getBank(Integer.valueOf(cBean.getAccountNumberId())); iMap.put("Bank code", bankAccount.getBankbranch().getBank().getCode()); iMap.put("Bank branch name", bankAccount.getBankbranch().getBranchaddress1()); iMap.put("Bank account id", bankAccount.getId()); iMap.put("Is pay cheque", "1"); iList.add(iMap); return iList; }
From source file:fr.paris.lutece.portal.service.admin.ImportAdminUserService.java
/** * {@inheritDoc}// w w w .j a v a2 s . c om */ @Override protected List<CSVMessageDescriptor> readLineOfCSVFile(String[] strLineDataArray, int nLineNumber, Locale locale, String strBaseUrl) { List<CSVMessageDescriptor> listMessages = new ArrayList<CSVMessageDescriptor>(); int nIndex = 0; String strAccessCode = strLineDataArray[nIndex++]; String strLastName = strLineDataArray[nIndex++]; String strFirstName = strLineDataArray[nIndex++]; String strEmail = strLineDataArray[nIndex++]; boolean bUpdateUser = getUpdateExistingUsers(); int nUserId = 0; if (bUpdateUser) { int nAccessCodeUserId = AdminUserHome.checkAccessCodeAlreadyInUse(strAccessCode); int nEmailUserId = AdminUserHome.checkEmailAlreadyInUse(strEmail); if (nAccessCodeUserId > 0) { nUserId = nAccessCodeUserId; } else if (nEmailUserId > 0) { nUserId = nEmailUserId; } bUpdateUser = nUserId > 0; } String strStatus = strLineDataArray[nIndex++]; int nStatus = 0; if (StringUtils.isNotEmpty(strStatus) && StringUtils.isNumeric(strStatus)) { nStatus = Integer.parseInt(strStatus); } else { Object[] args = { strLastName, strFirstName, nStatus }; String strMessage = I18nService.getLocalizedString(MESSAGE_NO_STATUS, args, locale); CSVMessageDescriptor message = new CSVMessageDescriptor(CSVMessageLevel.INFO, nLineNumber, strMessage); listMessages.add(message); } String strLocale = strLineDataArray[nIndex++]; String strLevelUser = strLineDataArray[nIndex++]; int nLevelUser = 3; if (StringUtils.isNotEmpty(strLevelUser) && StringUtils.isNumeric(strLevelUser)) { nLevelUser = Integer.parseInt(strLevelUser); } else { Object[] args = { strLastName, strFirstName, nLevelUser }; String strMessage = I18nService.getLocalizedString(MESSAGE_NO_LEVEL, args, locale); CSVMessageDescriptor message = new CSVMessageDescriptor(CSVMessageLevel.INFO, nLineNumber, strMessage); listMessages.add(message); } // We ignore the rest password attribute because we set it to true anyway. // String strResetPassword = strLineDataArray[nIndex++]; nIndex++; boolean bResetPassword = true; String strAccessibilityMode = strLineDataArray[nIndex++]; boolean bAccessibilityMode = Boolean.parseBoolean(strAccessibilityMode); // We ignore the password max valid date attribute because we changed the password. // String strPasswordMaxValidDate = strLineDataArray[nIndex++]; nIndex++; Timestamp passwordMaxValidDate = null; // We ignore the account max valid date attribute // String strAccountMaxValidDate = strLineDataArray[nIndex++]; nIndex++; Timestamp accountMaxValidDate = AdminUserService.getAccountMaxValidDate(); String strDateLastLogin = strLineDataArray[nIndex++]; Timestamp dateLastLogin = new Timestamp(AdminUser.DEFAULT_DATE_LAST_LOGIN.getTime()); if (StringUtils.isNotBlank(strDateLastLogin)) { DateFormat dateFormat = new SimpleDateFormat(); Date dateParsed; try { dateParsed = dateFormat.parse(strDateLastLogin); } catch (ParseException e) { AppLogService.error(e.getMessage(), e); dateParsed = null; } if (dateParsed != null) { dateLastLogin = new Timestamp(dateParsed.getTime()); } } AdminUser user = null; if (bUpdateUser) { user = AdminUserHome.findByPrimaryKey(nUserId); } else { user = new LuteceDefaultAdminUser(); } user.setAccessCode(strAccessCode); user.setLastName(strLastName); user.setFirstName(strFirstName); user.setEmail(strEmail); user.setStatus(nStatus); user.setUserLevel(nLevelUser); user.setLocale(new Locale(strLocale)); user.setAccessibilityMode(bAccessibilityMode); if (bUpdateUser) { user.setUserId(nUserId); // We update the user AdminUserHome.update(user); } else { // We create the user user.setPasswordReset(bResetPassword); user.setPasswordMaxValidDate(passwordMaxValidDate); user.setAccountMaxValidDate(accountMaxValidDate); user.setDateLastLogin(dateLastLogin); if (AdminAuthenticationService.getInstance().isDefaultModuleUsed()) { LuteceDefaultAdminUser defaultAdminUser = (LuteceDefaultAdminUser) user; String strPassword = AdminUserService.makePassword(); String strEncryptedPassword = AdminUserService.encryptPassword(strPassword); defaultAdminUser.setPassword(strEncryptedPassword); AdminUserHome.create(defaultAdminUser); // We un-encrypt the password to send it in an email defaultAdminUser.setPassword(strPassword); AdminUserService.notifyUser(AppPathService.getProdUrl(strBaseUrl), user, PROPERTY_MESSAGE_EMAIL_SUBJECT_NOTIFY_USER, TEMPLATE_NOTIFY_USER); } else { AdminUserHome.create(user); } } // We remove any previous right, roles, workgroup adn attributes of the user AdminUserHome.removeAllRightsForUser(user.getUserId()); AdminUserHome.removeAllRolesForUser(user.getUserId()); AdminUserFieldFilter auFieldFilter = new AdminUserFieldFilter(); auFieldFilter.setIdUser(user.getUserId()); AdminUserFieldHome.removeByFilter(auFieldFilter); // We get every attribute, role, right and workgroup of the user Map<Integer, List<String>> mapAttributesValues = new HashMap<Integer, List<String>>(); List<String> listAdminRights = new ArrayList<String>(); List<String> listAdminRoles = new ArrayList<String>(); List<String> listAdminWorkgroups = new ArrayList<String>(); while (nIndex < strLineDataArray.length) { String strValue = strLineDataArray[nIndex]; if (StringUtils.isNotBlank(strValue) && (strValue.indexOf(getAttributesSeparator()) > 0)) { int nSeparatorIndex = strValue.indexOf(getAttributesSeparator()); String strLineId = strValue.substring(0, nSeparatorIndex); if (StringUtils.isNotBlank(strLineId)) { if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_RIGHT)) { listAdminRights.add(strValue.substring(nSeparatorIndex + 1)); } else if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_ROLE)) { listAdminRoles.add(strValue.substring(nSeparatorIndex + 1)); } else if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_WORKGROUP)) { listAdminWorkgroups.add(strValue.substring(nSeparatorIndex + 1)); } else { int nAttributeId = Integer.parseInt(strLineId); String strAttributeValue = strValue.substring(nSeparatorIndex + 1); List<String> listValues = mapAttributesValues.get(nAttributeId); if (listValues == null) { listValues = new ArrayList<String>(); } listValues.add(strAttributeValue); mapAttributesValues.put(nAttributeId, listValues); } } } nIndex++; } // We create rights for (String strRight : listAdminRights) { AdminUserHome.createRightForUser(user.getUserId(), strRight); } // We create roles for (String strRole : listAdminRoles) { AdminUserHome.createRoleForUser(user.getUserId(), strRole); } // We create workgroups for (String strWorkgoup : listAdminWorkgroups) { AdminWorkgroupHome.addUserForWorkgroup(user, strWorkgoup); } List<IAttribute> listAttributes = _attributeService.getAllAttributesWithoutFields(locale); Plugin pluginCore = PluginService.getCore(); // We save the attributes found for (IAttribute attribute : listAttributes) { if (attribute instanceof ISimpleValuesAttributes) { List<String> listValues = mapAttributesValues.get(attribute.getIdAttribute()); if ((listValues != null) && (listValues.size() > 0)) { int nIdField = 0; boolean bCoreAttribute = (attribute.getPlugin() == null) || StringUtils.equals(pluginCore.getName(), attribute.getPlugin().getName()); for (String strValue : listValues) { int nSeparatorIndex = strValue.indexOf(getAttributesSeparator()); if (nSeparatorIndex >= 0) { nIdField = 0; try { nIdField = Integer.parseInt(strValue.substring(0, nSeparatorIndex)); } catch (NumberFormatException e) { nIdField = 0; } strValue = strValue.substring(nSeparatorIndex + 1); } else { nIdField = 0; } String[] strValues = { strValue }; try { List<AdminUserField> listUserFields = ((ISimpleValuesAttributes) attribute) .getUserFieldsData(strValues, user); for (AdminUserField userField : listUserFields) { if (userField != null) { userField.getAttributeField().setIdField(nIdField); AdminUserFieldHome.create(userField); } } if (!bCoreAttribute) { for (AdminUserFieldListenerService adminUserFieldListenerService : SpringContextService .getBeansOfType(AdminUserFieldListenerService.class)) { adminUserFieldListenerService.doCreateUserFields(user, listUserFields, locale); } } } catch (Exception e) { AppLogService.error(e.getMessage(), e); String strErrorMessage = I18nService .getLocalizedString(MESSAGE_ERROR_IMPORTING_ATTRIBUTES, locale); CSVMessageDescriptor error = new CSVMessageDescriptor(CSVMessageLevel.ERROR, nLineNumber, strErrorMessage); listMessages.add(error); } } } } } return listMessages; }
From source file:org.runnerup.export.RunKeeperSynchronizer.java
private String parseForNext(JSONObject resp, List<SyncActivityItem> items) throws JSONException { if (resp.has("items")) { JSONArray activities = resp.getJSONArray("items"); for (int i = 0; i < activities.length(); i++) { JSONObject item = activities.getJSONObject(i); SyncActivityItem ai = new SyncActivityItem(); String startTime = item.getString("start_time"); SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US); try { ai.setStartTime(TimeUnit.MILLISECONDS.toSeconds(format.parse(startTime).getTime())); } catch (ParseException e) { Log.e(Constants.LOG, e.getMessage()); return null; }/*w w w . ja va 2 s .c om*/ Float time = Float.parseFloat(item.getString("duration")); ai.setDuration(time.longValue()); BigDecimal dist = new BigDecimal(Float.parseFloat(item.getString("total_distance"))); dist = dist.setScale(2, BigDecimal.ROUND_UP); ai.setDistance(dist.floatValue()); ai.setURI(REST_URL + item.getString("uri")); ai.setId((long) items.size()); String sport = item.getString("type"); if (runkeeper2sportMap.containsKey(sport)) { ai.setSport(runkeeper2sportMap.get(sport).getDbValue()); } else { ai.setSport(Sport.OTHER.getDbValue()); } items.add(ai); } } if (resp.has("next")) { return REST_URL + resp.getString("next"); } return null; }
From source file:org.easy.test.criteria.CriteriaProcessorTest2.java
/** * /*from w ww . jav a 2 s . co m*/ * select * from course where course.last_update_date_time between ? and ? */ @Test public void testBetweenDates() { Date thatDate = null; try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); thatDate = simpleDateFormat.parse("2011-01-02 00:00:00"); } catch (ParseException e) { log.error(e); fail(e.getMessage()); } Date toDate = new Date(System.currentTimeMillis()); List<Course> result = criteriaProcessor .findAllEntity(CourseCriteria.findCouorseUpdatedBetween(thatDate, toDate), true, null); assertNotNull(result); assertEquals(2, result.size()); assertEquals("course2", result.get(0).getName()); }
From source file:org.easy.test.criteria.CriteriaProcessorTest2.java
/** * OrderBy// ww w . j a va2 s . co m * * select * from course * where course.last_update_date_time between ? and ? * order by course.name desc */ @Test public void testOrderBy() { Date thatDate = null; try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); thatDate = simpleDateFormat.parse("2011-01-02 00:00:00"); } catch (ParseException e) { log.error(e); fail(e.getMessage()); } Date toDate = new Date(System.currentTimeMillis()); CriteriaComposer<Course> criteria = CourseCriteria.findCouorseUpdatedBetween(thatDate, toDate); criteria.orderBy(Course_.name, false, 1); List<Course> result = criteriaProcessor.findAllEntity(criteria, true, null); assertNotNull(result); assertEquals(2, result.size()); assertEquals("course3", result.get(0).getName()); }
From source file:org.egov.collection.web.actions.receipts.BankRemittanceAction.java
@Override public void validate() { super.validate(); populateRemittanceList();/* www . java 2s. c o m*/ listData(); final SimpleDateFormat dateFomatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); if (receiptDateArray != null) { final String[] filterReceiptDateArray = removeNullValue(receiptDateArray); final String receiptEndDate = filterReceiptDateArray[filterReceiptDateArray.length - 1]; try { if (!receiptEndDate.isEmpty() && remittanceDate != null && remittanceDate.before(dateFomatter.parse(receiptEndDate))) addActionError(getText("bankremittance.before.receiptdate")); } catch (final ParseException e) { LOGGER.debug("Exception in parsing date " + receiptEndDate + " - " + e.getMessage()); throw new ApplicationRuntimeException("Exception while parsing receiptEndDate date", e); } } }