Example usage for java.util Calendar DAY_OF_MONTH

List of usage examples for java.util Calendar DAY_OF_MONTH

Introduction

In this page you can find the example usage for java.util Calendar DAY_OF_MONTH.

Prototype

int DAY_OF_MONTH

To view the source code for java.util Calendar DAY_OF_MONTH.

Click Source Link

Document

Field number for get and set indicating the day of the month.

Usage

From source file:org.wikipedia.nirvana.statistics.ArchiveItem.java

public ArchiveItem(Revision r, int size) {
    this.article = HTTPTools.removeEscape(r.getPage());
    this.user = HTTPTools.removeEscape(r.getUser());
    Calendar c = r.getTimestamp();
    this.year = c.get(Calendar.YEAR);
    this.month = c.get(Calendar.MONTH);
    this.day = c.get(Calendar.DAY_OF_MONTH);
    this.size = size;
}

From source file:com.chortitzer.web.fps.controller.VaporBean.java

/**
 * @param selectedRango the selectedRango to set
 *//*from w w  w. j  av a2  s .  com*/
public void setSelectedRango(int selectedRango) {
    this.selectedRango = selectedRango;
    if (selectedRango != 0) {
        setFechaHasta(new Date());
        switch (selectedRango) {
        case 1:
            setFechaDesde(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH));
            break;
        case 2:
            fechaDesde = DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
            setFechaDesde(DateUtils.addDays(fechaDesde, -1));
            fechaHasta = DateUtils.addDays(fechaDesde, 1);
            setFechaHasta(DateUtils.addMilliseconds(fechaHasta, -1));
            break;
        case 3:
            calendar = DateUtils.truncate(calendar, Calendar.DAY_OF_MONTH);
            calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek());
            setFechaDesde(calendar.getTime());
            break;
        case 4:
            setFechaDesde(DateUtils.truncate(new Date(), Calendar.MONTH));
            break;
        case 5:
            setFechaDesde(DateUtils.truncate(new Date(), Calendar.YEAR));
            break;
        }
    }
    createDataModel();
}

From source file:net.ceos.project.poi.annotated.bean.BasicObjectBuilder.java

/**
 * Validate the BasicObject based on the object build with the method
 * 'buildBasicObject'/*ww w  . ja  v  a 2s.c om*/
 * 
 * @param toValidate
 *            the object to validate
 */
public static void validateBasicObject(BasicObject toValidate) {
    BasicObject base = buildBasicObject();

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    Calendar calendarUnmarshal = Calendar.getInstance();
    calendarUnmarshal.setTime(toValidate.getDateAttribute());
    assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR));
    assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH));
    assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH));
    assertEquals(base.getStringAttribute(), toValidate.getStringAttribute());
    assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute());
    assertEquals(base.getLongAttribute(), toValidate.getLongAttribute());
    assertEquals(base.isBooleanPrimitiveAttribute(), toValidate.isBooleanPrimitiveAttribute());
    assertEquals(base.getFloatPrimitiveAttribute(), toValidate.getFloatPrimitiveAttribute());
    assertEquals(base.getUnitFamily(), toValidate.getUnitFamily());
    assertEquals(base.getBigDecimalAttribute(), toValidate.getBigDecimalAttribute());
    // TODO add new validation below
}

From source file:erpsystem.chart.Charts.java

private static Calendar copyCalendar(Calendar calendar) {
    Calendar result = Calendar.getInstance();
    result.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH),
            calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
    return result;
}

From source file:net.ceos.project.poi.annotated.bean.cascade.CascadeL3Builder.java

/**
 * Validate the CascadeL3 based on the object build with the method
 * 'buildCascadeL3'//from w  w w.j a  v a 2  s. c o m
 * 
 * @param toValidate
 *            the object to validate
 */
public static void validateCascadeL3(CascadeL3 toValidate) {
    CascadeL3 base = buildCascadeL3();

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    Calendar calendarUnmarshal = Calendar.getInstance();
    calendarUnmarshal.setTime(toValidate.getDateAttribute());
    assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR));
    assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH));
    assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH));

    assertEquals(base.getStringAttribute(), toValidate.getStringAttribute());
    assertEquals(base.getIntegerAttribute(), toValidate.getIntegerAttribute());
    assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute());
    assertEquals(base.getLongAttribute(), toValidate.getLongAttribute());
    assertEquals(base.getBooleanAttribute(), toValidate.getBooleanAttribute());
    assertEquals(base.getJob().getJobCode(), toValidate.getJob().getJobCode());
    assertEquals(base.getJob().getJobFamily(), toValidate.getJob().getJobFamily());
    assertEquals(base.getJob().getJobName(), toValidate.getJob().getJobName());

    // TODO add new validation below
}

From source file:org.openhie.openempi.util.DateConverterTest.java

public void testConvertStringToDate() throws Exception {
    Date today = new Date();
    Calendar todayCalendar = new GregorianCalendar();
    todayCalendar.setTime(today);//  ww  w. ja v a 2  s .  c o m
    String datePart = DateUtil.convertDateToString(today);

    Date date = (Date) converter.convert(Date.class, datePart);

    Calendar cal = new GregorianCalendar();
    cal.setTime(date);
    assertEquals(todayCalendar.get(Calendar.YEAR), cal.get(Calendar.YEAR));
    assertEquals(todayCalendar.get(Calendar.MONTH), cal.get(Calendar.MONTH));
    assertEquals(todayCalendar.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH));
}

From source file:com.manning.androidhacks.hack009.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from   ww w.  ja  v  a  2 s . co  m

    // get the current date
    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);

    mDateSetListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Toast.makeText(MainActivity.this,
                    getString(R.string.picked_date_format, monthOfYear, dayOfMonth, year), Toast.LENGTH_SHORT)
                    .show();
        }
    };

    findViewById(R.id.details_date).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
        }
    });
}

From source file:de.fischer.thotti.reportgen.combiner.MedianIterator.java

@Override
DatePoint getNextElementComputed() {/*from  www.  j  a  v a2  s  . com*/
    double medianValue;
    int numOfValues = elements.size();
    int remainder = numOfValues % 2;
    int idxFirstElementAboveMedian = ((numOfValues - remainder) / 2) - 1
            - 1 /* Adjustment for 0 based index of collections. */;

    System.out.println("E: " + elements.size());
    System.out.println("R: " + remainder);

    Iterator<NDResultEntity> itr = elements.iterator();

    for (int index = 0; index <= idxFirstElementAboveMedian; index++) {
        itr.next();
    }

    NDResultEntity firstAboveMedian = itr.next();
    double executionTimeA = firstAboveMedian.getExecutionTime();

    if (numOfValues == 1) {
        medianValue = executionTimeA;

    } else {
        NDResultEntity firstBelowMedian = itr.next();

        double executionTimeB = firstBelowMedian.getExecutionTime();
        medianValue = (executionTimeA + executionTimeB) / 2;
    }

    DatePoint result = new DatePoint();

    Date date = DateUtils.truncate(firstAboveMedian.getStartedAt(), Calendar.DAY_OF_MONTH);
    result.setPointInTime(date);
    result.setValue(medianValue);

    return result;
}

From source file:edu.wisc.my.stats.query.support.UWDataWareHouseInformationProvider.java

/**
 * @see edu.wisc.my.stats.query.DatabaseInformationProvider#getDateConstraintString(java.util.Date, java.util.Date)
 *///ww w.j a  v a  2  s .  c  o  m
public String getDateConstraintString(Date start, Date end) {
    final Calendar startCal = Calendar.getInstance();
    startCal.setTime(start);

    final Calendar endCal = Calendar.getInstance();
    endCal.setTime(end);

    final StringBuilder dateConstraint = new StringBuilder();

    dateConstraint.append("DD.FULL_DATE ");

    if (startCal.get(Calendar.YEAR) == endCal.get(Calendar.YEAR)
            && startCal.get(Calendar.MONTH) == endCal.get(Calendar.MONTH)
            && startCal.get(Calendar.DAY_OF_MONTH) == endCal.get(Calendar.DAY_OF_MONTH)) {
        dateConstraint.append("= ");
        this.addDateConstraint(dateConstraint, start);
    } else {
        dateConstraint.append("BETWEEN ");
        this.addDateConstraint(dateConstraint, start);
        dateConstraint.append(" AND ");
        this.addDateConstraint(dateConstraint, end);
    }

    return dateConstraint.toString();
}

From source file:com.biosis.biosislite.interpretes.InterpreteTardanzaMensual.java

@Override
public List<RptTardanzaMensual> interpretar(List<Asistencia> registroAsistencia) {
    List<RptTardanzaMensual> tardanzas = new ArrayList<>();
    Calendar iterador = Calendar.getInstance();
    if (!registroAsistencia.isEmpty()) {
        double total = 0.0;
        Empleado empleado = registroAsistencia.get(0).getEmpleado();
        RptTardanzaMensual tardanzaMensual = new RptTardanzaMensual();
        tardanzaMensual.setEmpleado(empleado);
        tardanzaMensual.setFecha(registroAsistencia.get(0).getFecha());

        for (Asistencia asistencia : registroAsistencia) {
            if (asistencia.getResultado() == AnalizadorAsistencia.ASISTENCIA) {
                if (!empleado.equals(asistencia.getEmpleado())) {
                    tardanzaMensual.setTotal(total);
                    tardanzas.add(tardanzaMensual);
                    empleado = asistencia.getEmpleado();
                    tardanzaMensual = new RptTardanzaMensual();
                    tardanzaMensual.setEmpleado(empleado);
                    tardanzaMensual.setFecha(iterador.getTime());
                }// w ww  . j a v  a 2  s.  c o  m
                iterador.setTime(asistencia.getFecha());
                int dia = iterador.get(Calendar.DAY_OF_MONTH);
                System.out.println("DIA: " + dia);
                try {
                    double tardanzaDia = this.minutosTardanza(asistencia.getDetalleAsistenciaList());
                    String valor = BeanUtils.getProperty(tardanzaMensual, "dia" + dia);
                    double valorDouble = Double.parseDouble(valor);
                    total += tardanzaDia;
                    valorDouble += tardanzaDia;
                    System.out.println(String.format("TOTAL: %s VALOR: %s", total, valorDouble));
                    BeanUtils.setProperty(tardanzaMensual, "dia" + dia, valorDouble);
                } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
                    Logger.getLogger(InterpreteTardanzaMensual.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

        }
        tardanzaMensual.setTotal(total);
        tardanzas.add(tardanzaMensual);

    }

    return tardanzas;
}