Example usage for org.joda.time MutableDateTime MutableDateTime

List of usage examples for org.joda.time MutableDateTime MutableDateTime

Introduction

In this page you can find the example usage for org.joda.time MutableDateTime MutableDateTime.

Prototype

public MutableDateTime(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:com.lithium.yoda.HourOfDay.java

License:Apache License

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    loi = PrimitiveObjectInspectorFactory.javaLongObjectInspector;
    dt = new MutableDateTime(0);
    return PrimitiveObjectInspectorFactory.javaIntObjectInspector;
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToMinute(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//w  ww  . ja  v a2s. c o m
    result.setSecondOfMinute(0);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToHour(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);/*from   ww w  .  j a v  a 2  s. c  om*/
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToDay(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//from   www.  j ava  2  s  . com
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToMonth(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//from w ww .  jav  a  2 s  .c o  m
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    result.setDayOfMonth(1);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToWeek(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//from  ww w . j a  va2s. c om
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    result.setHourOfDay(0);

    if (time.getDayOfWeek() != 7) {
        result.setDayOfWeek(1);
        result.add(Days.ONE.multipliedBy(-1));
    }

    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToYear(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//from   ww  w  .j av a 2 s  .c  o  m
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    result.setDayOfMonth(1);
    result.setMonthOfYear(1);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.writer.EventRate.java

License:Apache License

public DateTime truncateToSecond(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);/*from  w  w w.j ava2s  .  c  o  m*/
    return new DateTime(result);
}

From source file:com.simopuve.rest.SimopuveRESTServices.java

@Path("/reports")
@GET// w w  w.  j a v a  2  s  . c om
@Produces("text/plain")
public String getReportByDateInterval(@QueryParam("from") String from, @QueryParam("to") String to) {
    Date start;
    Date end;
    if (from == null) {
        start = new Date();
    } else {
        try {
            start = new SimpleDateFormat("dd/MM/yyyy").parse(from);
        } catch (ParseException ex) {
            start = new Date();
            Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (to == null) {
        end = new Date();
    } else {
        try {
            end = new SimpleDateFormat("dd/MM/yyyy").parse(to);
        } catch (ParseException ex) {
            end = new Date();
            Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    org.joda.time.format.DateTimeFormatter fmt = DateTimeFormat.forPattern("dd-MM-yyy");
    DateTime startDate = new DateTime(start);
    DateTime endDate = new DateTime(end);
    Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "Received UA: " + start);
    Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "Received UA: " + from);
    Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "Received UA: " + startDate);
    MutableDateTime currentDate = new MutableDateTime(startDate);
    List<PDVSurvey> surveyList = new ArrayList<>();
    File currentFolder;
    File mallFolder;
    File officeFolder;
    File tmpFolder;
    String varPath;
    String tmpPath;
    PDVSurvey survey = null;
    Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "Received startdate: " + startDate);
    while (!currentDate.isAfter(endDate)) {
        varPath = new StringBuilder(System.getProperty("jboss.server.data.dir")).append("/PDV/")
                .append(currentDate.toString(fmt)).append("/").toString();
        currentFolder = new File(varPath);

        if (currentFolder.exists()) {
            mallFolder = new File(varPath + "/Mall");
            officeFolder = new File(varPath + "/Oficina");
            if (mallFolder.exists()) {
                for (File fileEntry : mallFolder.listFiles()) {
                    try {
                        Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "archivo {0} ",
                                fileEntry.getName());
                        tmpPath = varPath + "/Mall/" + fileEntry.getName();
                        survey = getPDVSurveyFromFile(tmpPath, true);
                        surveyList.add(survey);

                    } catch (IOException ex) {
                        Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
            if (officeFolder.exists()) {
                for (File fileEntry : officeFolder.listFiles()) {
                    try {
                        Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "archivo {0} ",
                                fileEntry.getName());
                        tmpPath = varPath + "/Oficina/" + fileEntry.getName();
                        survey = getPDVSurveyFromFile(tmpPath, false);
                        surveyList.add(survey);
                    } catch (IOException ex) {
                        Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
        Logger.getLogger(SimopuveRESTServices.class.getName()).log(Level.INFO, "-+-+-+-tamao de lista {0} ",
                surveyList.size());
        currentDate.addDays(1);
    }

    String filePath = new StringBuilder(System.getProperty("jboss.server.data.dir"))
            .append("/PDV/testFlow.xlsx").toString();

    Workbook flowWorkbook = POIHelper.getWorkbookFromLocalReource("plantilla-base-flujo.xlsx");
    FillFlowBaseSheet(surveyList, flowWorkbook.getSheetAt(0));
    FillDetailBaseSheet(surveyList, flowWorkbook.getSheetAt(1));
    POIHelper.writeWorkbookInPath(flowWorkbook, filePath);

    return "Listo";
}

From source file:com.soen.hasslefree.beans.AppointmentEventListener.java

public void fetchTimeSlotListForPhysician(ValueChangeEvent e) {
    AppointmentBean appointment = (AppointmentBean) FacesContext.getCurrentInstance().getExternalContext()
            .getRequestMap().get("appointmentBean");
    long ChangedPhysicianId = (Long) e.getNewValue();
    MutableDateTime dateEntered = new MutableDateTime(dateHolder);

    List<String> timeSlotHolder = new ArrayList<String>();
    appointment.setRelatedPhysician(ChangedPhysicianId);
    ArrayList<PhysicianTimeSlot> timeSlotListDI = null;
    ArrayList<ArrayList<PhysicianTimeSlot>> timeSlotListCU = null;
    //Getting Clinic Starting and ending times
    ArrayList<ClinicHours> clinicHours = ClinicHours.getAllClinicHours();
    //Check forselected appointment type
    //        if ((dateEntered.isEqual(clinicHours.get(0).getStartTime()) || dateEntered.isAfter(clinicHours.get(0).getStartTime())) && dateEntered.isBefore(clinicHours.get(0).getEndTime())) {
    if (appointmentType.equals("Drop In")) {
        timeSlotListDI = Appointment.getAvailableDropInByPhysicianID(ChangedPhysicianId,
                clinicHours.get(0).getStartTime(), clinicHours.get(0).getEndTime());
        // Persisting values to access from request scoped (Appointment Bean)
        timeSlotListDIBackup = timeSlotListDI;
        for (PhysicianTimeSlot timeSlot : timeSlotListDI) {
            String hourDI = Integer.toString(timeSlot.getStartTime().getHourOfDay());
            String minutesDI = Integer.toString(timeSlot.getStartTime().getMinuteOfHour());

            if (minutesDI.equals("0")) {
                minutesDI = "00";
            }//from w ww  . j a  v  a  2  s. co m
            if (hourDI.length() == 1) {
                hourDI = "0" + hourDI;
            }
            timeSlotHolder.add(hourDI + ":" + minutesDI);
        }
    }
    if (appointmentType.equals("Annual Check Up")) {
        timeSlotListCU = Appointment.getallAvailableCheckUpsByPhysicianID(ChangedPhysicianId,
                clinicHours.get(0).getStartTime(), clinicHours.get(0).getEndTime());
        // Persisting values to access from request scoped (Appointment Bean)
        timeSlotListCUBackup = timeSlotListCU;
        for (int i = 0; i < timeSlotListCU.size(); i++) {
            String hourCU = Integer.toString(timeSlotListCU.get(i).get(0).getStartTime().getHourOfDay());
            String minutesCU = Integer.toString(timeSlotListCU.get(i).get(0).getStartTime().getMinuteOfHour());

            if (minutesCU.equals("0")) {
                minutesCU = "00";
            }
            if (hourCU.length() == 1) {
                hourCU = "0" + hourCU;
            }
            timeSlotHolder.add(hourCU + ":" + minutesCU);
            i += 2;
        }
    }

    timeSlots = timeSlotHolder;
    //        }
}