Search in sources :

Example 26 with DateTimeFormatter

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;
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 27 with DateTimeFormatter

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;
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 28 with DateTimeFormatter

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;
}
Also used : HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with DateTimeFormatter

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;
    }
}
Also used : Duration(org.joda.time.Duration) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 30 with DateTimeFormatter

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;
    }
}
Also used : InvalidValueException(org.teleal.cling.model.types.InvalidValueException) Action(org.teleal.cling.model.meta.Action) PeriodFormatterBuilder(org.joda.time.format.PeriodFormatterBuilder) PeriodFormatter(org.joda.time.format.PeriodFormatter) ActionInvocation(org.teleal.cling.model.action.ActionInvocation) Service(org.teleal.cling.model.meta.Service) UpnpService(org.teleal.cling.UpnpService) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) UDAServiceId(org.teleal.cling.model.types.UDAServiceId)

Aggregations

DateTimeFormatter (org.joda.time.format.DateTimeFormatter)189 DateTime (org.joda.time.DateTime)88 Date (java.util.Date)40 Test (org.junit.Test)25 DateTimeZone (org.joda.time.DateTimeZone)19 ArrayList (java.util.ArrayList)14 SolrInputDocument (org.apache.solr.common.SolrInputDocument)12 IndexSchema (org.apache.solr.schema.IndexSchema)12 DateTimeFormatterBuilder (org.joda.time.format.DateTimeFormatterBuilder)12 HashMap (java.util.HashMap)10 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)10 IOException (java.io.IOException)9 Calendar (java.util.Calendar)8 Map (java.util.Map)8 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)7 FormatDateTimeFormatter (org.elasticsearch.common.joda.FormatDateTimeFormatter)7 Test (org.testng.annotations.Test)7 TimeSpec (com.linkedin.thirdeye.api.TimeSpec)6 FilterType (net.opengis.filter.v_1_1_0.FilterType)6 Deployment (org.activiti.engine.test.Deployment)6