use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class LoanAccountActionForm method validateSumOfTheAmountsSpecified.
void validateSumOfTheAmountsSpecified(ActionErrors errors) {
List<String> ids_clients_selected = getClients();
double totalAmount = new Double(0);
boolean foundInvalidAmount = false;
for (LoanAccountDetailsDto loanDetail : getClientDetails()) {
if (!foundInvalidAmount) {
if (ids_clients_selected.contains(loanDetail.getClientId())) {
if (isAmountZeroOrNull(loanDetail.getLoanAmount())) {
addError(errors, LoanExceptionConstants.CUSTOMER_LOAN_AMOUNT_FIELD);
foundInvalidAmount = true;
} else {
totalAmount = totalAmount + new LocalizationConverter().getDoubleValueForCurrentLocale(loanDetail.getLoanAmount());
}
}
}
}
if (!foundInvalidAmount && (StringUtils.isBlank(Double.valueOf(totalAmount).toString()) || !amountRange.isInRange(totalAmount))) {
addError(errors, LoanConstants.LOANAMOUNT, LoanExceptionConstants.SUM_OF_INDIVIDUAL_AMOUNTS_IS_NOT_IN_THE_RANGE_OF_ALLOWED_AMOUNTS, getStringValue(amountRange.getMinLoanAmount()), getStringValue(amountRange.getMaxLoanAmount()));
}
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class CollectionSheetEntryDto method setCustomerAccountAmountEntered.
public void setCustomerAccountAmountEntered(final String customerAccountAmountEntered) {
customerAccountDetails.setCustomerAccountAmountEntered(customerAccountAmountEntered);
try {
new LocalizationConverter().getDoubleValueForCurrentLocale(customerAccountAmountEntered);
customerAccountDetails.setValidCustomerAccountAmountEntered(true);
} catch (NumberFormatException nfe) {
customerAccountDetails.setValidCustomerAccountAmountEntered(false);
}
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class DateUtils method convertToMFIFormat.
public static String convertToMFIFormat(String date, String format) {
String MFIString;
String MFIfmt = getMFIFormat();
String day = "";
String month = "";
String year = "";
String token;
String separator = new LocalizationConverter().getDateSeparatorForCurrentLocale();
MFIfmt = convertToDateTagFormat(MFIfmt);
StringTokenizer stfmt = new StringTokenizer(format, separator);
StringTokenizer stdt = new StringTokenizer(date, separator);
while (stfmt.hasMoreTokens() && stdt.hasMoreTokens()) {
token = stfmt.nextToken();
if (token.equalsIgnoreCase("D")) {
day = stdt.nextToken();
} else if (token.equalsIgnoreCase("M")) {
month = stdt.nextToken();
} else {
year = stdt.nextToken();
}
}
MFIString = createDateString(day, month, year, MFIfmt);
return MFIString;
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class MifosDoubleConverterTest method xtestConvert_is_IS.
/**
* Currently broken -- incomplete support for multiple locales for numeric input.
*/
@Ignore
public void xtestConvert_is_IS() {
LocalizationConverter converter = new LocalizationConverter();
converter.setCurrentLocale(new Locale("IS", "is"));
Assert.assertEquals(new Double(2.0), mifosDoubleConverter.convert(String.class, "2,0"));
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class FiscalCalendarRulesTest method testIsWorkingDay.
@Test
public void testIsWorkingDay() {
String configWorkingDays = "MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY";
setNewWorkingDays(configWorkingDays);
// get the supported ids for GMT-08:00 (Pacific Standard Time)
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
// if no ids were returned, something is wrong. get out.
// Otherwise get an id for Pacific Standard Time
String pstId = ids[0];
// create a Pacific Standard Time time zone
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, pstId);
// set up rules for daylight savings time
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
// create a GregorianCalendar with the Pacific Daylight time zone
// and the current date and time
Calendar calendar = new GregorianCalendar(pdt);
try {
Locale savedLocale = Localization.getInstance().getConfiguredLocale();
new LocalizationConverter().setCurrentLocale(Locale.US);
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
// Keith: DateFormat must be set to the same timezone as the
// calendar
// Otherwise dates don't roll over at the same exact time, causing
// this and several other unit tests to fail
df.setTimeZone(TimeZone.getTimeZone(pstId));
df.applyPattern("yyyy/MM/dd");
Date thursday = df.parse("2007/10/11");
calendar.setTime(thursday);
String out = thursday.toString();
out.contains("A");
new LocalizationConverter().setCurrentLocale(savedLocale);
} catch (Exception e) {
}
Assert.assertTrue(new FiscalCalendarRules().isWorkingDay(calendar));
// Friday
calendar.add(Calendar.DAY_OF_WEEK, 1);
Assert.assertTrue(new FiscalCalendarRules().isWorkingDay(calendar));
// Sat
calendar.add(Calendar.DAY_OF_WEEK, 1);
Assert.assertTrue(!new FiscalCalendarRules().isWorkingDay(calendar));
// Sunday
calendar.add(Calendar.DAY_OF_WEEK, 1);
Assert.assertTrue(!new FiscalCalendarRules().isWorkingDay(calendar));
}
Aggregations