use of java.text.ParseException in project Openfire by igniterealtime.
the class Application method getDouble.
private double getDouble(String value) throws ParseException {
int n;
if ((n = value.indexOf(":")) > 0) {
value = value.substring(0, n);
}
double f = 0.0;
try {
f = Double.parseDouble(value);
} catch (NumberFormatException e) {
throw new ParseException("Invalid double value: " + value, 0);
}
return f;
}
use of java.text.ParseException in project head by mifos.
the class DateUtils method convertUserToDbFmt.
public static String convertUserToDbFmt(String userDate, String userPattern) throws InvalidDateException {
try {
SimpleDateFormat userFormat = new SimpleDateFormat(userPattern, dateLocale);
// userFormat.setLenient(false);
java.util.Date date = userFormat.parse(userDate);
return toDatabaseFormat(date);
} catch (ParseException e) {
throw new InvalidDateException(userDate);
}
}
use of java.text.ParseException in project head by mifos.
the class DateUtils method convertDbToUserFmt.
public static String convertDbToUserFmt(String dbDate, String userPattern) throws InvalidDateException {
try {
SimpleDateFormat databaseFormat = new SimpleDateFormat(dbFormat, dateLocale);
java.util.Date date = databaseFormat.parse(dbDate);
SimpleDateFormat userFormat = new SimpleDateFormat(userPattern);
return userFormat.format(date);
} catch (ParseException e) {
throw new InvalidDateException(dbDate, e);
}
}
use of java.text.ParseException in project head by mifos.
the class DateUtils method getDateAsSentFromBrowser.
/**
* "as sent from browser" is a bit of a misnomer; it really is (at least in
* many cases), as formatted by a routine on the server side like
* ClientCustActionForm#getDateOfBirth()
*
* @throws InvalidDateException
*/
public static java.sql.Date getDateAsSentFromBrowser(String value) throws InvalidDateException {
if (value == null || value == "") {
return null;
}
try {
String formatStr = "d" + dateSeparator + "M" + dateSeparator + "yy";
SimpleDateFormat format = new SimpleDateFormat(formatStr, internalLocale);
format.setLenient(false);
return new java.sql.Date(format.parse(value).getTime());
} catch (ParseException e) {
throw new InvalidDateException(value);
}
}
use of java.text.ParseException in project head by mifos.
the class MifosBatchJob method computeMissedJobLaunches.
@SuppressWarnings("unchecked")
public List<Date> computeMissedJobLaunches(Date from, Date to, Trigger trigger, boolean onDemandRun) throws Exception {
List<Date> missedLaunches = new LinkedList<Date>();
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = new CronTrigger();
cronTrigger.setStartTime(from);
cronTrigger.setNextFireTime(from);
String cronExpression = ((CronTrigger) trigger).getCronExpression();
try {
cronTrigger.setCronExpression(cronExpression);
} catch (ParseException pe) {
throw new Exception(pe);
}
List<Date> computationOutcome = TriggerUtils.computeFireTimesBetween(cronTrigger, null, from, to);
missedLaunches.addAll(computationOutcome);
missedLaunches.remove(0);
if (!onDemandRun && missedLaunches.size() > 0) {
missedLaunches.remove(missedLaunches.size() - 1);
}
} else if (trigger instanceof SimpleTrigger) {
SimpleTrigger simpleTrigger = new SimpleTrigger();
simpleTrigger.setStartTime(from);
simpleTrigger.setNextFireTime(from);
simpleTrigger.setRepeatInterval(((SimpleTrigger) trigger).getRepeatInterval());
simpleTrigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
List<Date> computationOutcome = TriggerUtils.computeFireTimesBetween(simpleTrigger, null, from, to);
missedLaunches.addAll(computationOutcome);
missedLaunches.remove(0);
if (!onDemandRun && missedLaunches.size() > 0) {
missedLaunches.remove(missedLaunches.size() - 1);
}
}
return missedLaunches;
}
Aggregations