use of org.joda.time.format.DateTimeFormatter in project head by mifos.
the class LoanScheduleFormBean method parseInstallment.
public String parseInstallment(int index) {
DateTimeFormatter formatter = org.joda.time.format.DateTimeFormat.forStyle("S-").withLocale(Locale.getDefault());
DateTime dueDate = this.installments.get(index);
String printedDate = "";
if (dueDate != null) {
printedDate = formatter.print(dueDate);
}
return printedDate;
}
use of org.joda.time.format.DateTimeFormatter in project head by mifos.
the class LoanScheduleFormBean method parseActualPaymentDates.
public String parseActualPaymentDates(int index) {
DateTimeFormatter formatter = org.joda.time.format.DateTimeFormat.forStyle("S-").withLocale(Locale.getDefault());
DateTime actualPaymentDate = this.actualPaymentDates.get(index);
String printedDate = "";
if (actualPaymentDate != null) {
printedDate = formatter.print(actualPaymentDate);
}
return printedDate;
}
use of org.joda.time.format.DateTimeFormatter in project head by mifos.
the class DateTimeUpdateController method handleRequestInternal.
@Override
@RequestMapping("/dateTimeUpdate.ftl")
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
ModelAndView returnValue = new ModelAndView("pageNotFound");
if (TestMode.MAIN == getTestingService().getTestMode()) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
} else {
String dateTimeString = request.getParameter("dateTime");
String result = null;
if (null == dateTimeString) {
result = "Missing 'dateTime' parameter!";
} else if ("system".equals(dateTimeString)) {
getDateTimeService().resetToCurrentSystemDateTime();
result = getDateTimeService().getCurrentDateTime().toString();
} else {
DateTimeFormatter formatter = ISODateTimeFormat.basicDateTimeNoMillis();
DateTime dateTime = formatter.parseDateTime(dateTimeString);
getDateTimeService().setCurrentDateTime(dateTime);
result = dateTime.toString();
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("updateResult", result);
model.put("request", request);
Map<String, Object> status = new HashMap<String, Object>();
List<String> errorMessages = new ArrayList<String>();
status.put("errorMessages", errorMessages);
ModelAndView modelAndView = new ModelAndView("dateTimeUpdate", "model", model);
modelAndView.addObject("status", status);
returnValue = modelAndView;
}
return returnValue;
}
use of org.joda.time.format.DateTimeFormatter in project openhab1-addons by openhab.
the class SonosZonePlayer method setAlarm.
public boolean setAlarm(boolean alarmSwitch) {
List<SonosAlarm> sonosAlarms = getCurrentAlarmList();
if (isConfigured()) {
// find the nearest alarm - take the current time from the Sonos System, not the system where openhab is
// running
String currentLocalTime = getTime();
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
DateTime currentDateTime = fmt.parseDateTime(currentLocalTime);
Duration shortestDuration = Period.days(10).toStandardDuration();
SonosAlarm firstAlarm = null;
for (SonosAlarm anAlarm : sonosAlarms) {
Duration duration = new Duration(currentDateTime, anAlarm.getStartTime());
if (anAlarm.getStartTime().isBefore(currentDateTime.plus(shortestDuration)) && anAlarm.getRoomUUID().equals(udn.getIdentifierString())) {
shortestDuration = duration;
firstAlarm = anAlarm;
}
}
// Set the Alarm
if (firstAlarm != null) {
if (alarmSwitch) {
firstAlarm.setEnabled(true);
} else {
firstAlarm.setEnabled(false);
}
return updateAlarm(firstAlarm);
} else {
return false;
}
} else {
return false;
}
}
use of org.joda.time.format.DateTimeFormatter in project openhab1-addons by openhab.
the class SonosZonePlayer method updateAlarm.
public boolean updateAlarm(SonosAlarm alarm) {
if (alarm != null && isConfigured()) {
Service service = device.findService(new UDAServiceId("AlarmClock"));
Action action = service.getAction("ListAlarms");
ActionInvocation invocation = new ActionInvocation(action);
DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss");
PeriodFormatter pFormatter = new PeriodFormatterBuilder().printZeroAlways().appendHours().appendSeparator(":").appendMinutes().appendSeparator(":").appendSeconds().toFormatter();
try {
invocation.setInput("ID", Integer.toString(alarm.getID()));
invocation.setInput("StartLocalTime", formatter.print(alarm.getStartTime()));
invocation.setInput("Duration", pFormatter.print(alarm.getDuration()));
invocation.setInput("Recurrence", alarm.getRecurrence());
invocation.setInput("RoomUUID", alarm.getRoomUUID());
invocation.setInput("ProgramURI", alarm.getProgramURI());
invocation.setInput("ProgramMetaData", alarm.getProgramMetaData());
invocation.setInput("PlayMode", alarm.getPlayMode());
invocation.setInput("Volume", Integer.toString(alarm.getVolume()));
if (alarm.getIncludeLinkedZones()) {
invocation.setInput("IncludeLinkedZones", "1");
} else {
invocation.setInput("IncludeLinkedZones", "0");
}
if (alarm.getEnabled()) {
invocation.setInput("Enabled", "1");
} else {
invocation.setInput("Enabled", "0");
}
} catch (InvalidValueException ex) {
logger.error("Action Invalid Value Exception {}", ex.getMessage());
} catch (NumberFormatException ex) {
logger.error("Action Invalid Value Format Exception {}", ex.getMessage());
}
executeActionInvocation(invocation);
return true;
} else {
return false;
}
}
Aggregations