Example usage for java.util Calendar MINUTE

List of usage examples for java.util Calendar MINUTE

Introduction

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

Prototype

int MINUTE

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

Click Source Link

Document

Field number for get and set indicating the minute within the hour.

Usage

From source file:com.ar.dev.tierra.api.dao.impl.ChartDAOImpl.java

@SuppressWarnings("unchecked")
@Override/*from w ww . j  ava2s . co  m*/
public List<Chart> getVentaVendedores(int idVendedor) {
    Calendar calendarInitial = Calendar.getInstance();
    Calendar calendarClosing = Calendar.getInstance();
    calendarInitial.set(Calendar.HOUR_OF_DAY, 0);
    calendarInitial.set(Calendar.MINUTE, 0);
    calendarInitial.set(Calendar.SECOND, 0);
    calendarInitial.set(Calendar.MILLISECOND, 0);
    Date fromDate = calendarInitial.getTime();
    calendarClosing.set(Calendar.HOUR_OF_DAY, 23);
    calendarClosing.set(Calendar.MINUTE, 59);
    calendarClosing.set(Calendar.SECOND, 59);
    calendarClosing.set(Calendar.MILLISECOND, 59);
    Date toDate = calendarClosing.getTime();
    int days = 0;
    List<Chart> chartVenta = new ArrayList<>();
    while (days <= 6) {
        Chart chart = new Chart();
        Criteria facturas = getSession().createCriteria(Factura.class);
        facturas.add(Restrictions.like("estado", "CONFIRMADO"));
        facturas.add(Restrictions.between("fechaCreacion", fromDate, toDate));
        Criteria vendedorFactura = facturas.createCriteria("idVendedor");
        vendedorFactura.add(Restrictions.eq("idUsuario", idVendedor));
        vendedorFactura.setProjection(Projections.rowCount());
        Long counter = (Long) facturas.uniqueResult();
        chart.setValue(counter.intValue());
        chart.setDate(fromDate);
        chartVenta.add(chart);
        calendarInitial.add(Calendar.DAY_OF_MONTH, -1);
        fromDate = calendarInitial.getTime();
        calendarClosing.add(Calendar.DAY_OF_MONTH, -1);
        toDate = calendarClosing.getTime();
        days++;
    }
    return chartVenta;
}

From source file:thymeleafsandbox.springjsp.web.controller.jsp.JspForm.java

@ModelAttribute("user")
public User populateUser() {
    final User user = new User();
    final Calendar registrationDate = Calendar.getInstance();
    registrationDate.set(Calendar.MILLISECOND, 0);
    registrationDate.set(Calendar.SECOND, 0);
    registrationDate.set(Calendar.MINUTE, 0);
    registrationDate.set(Calendar.HOUR, 0);
    user.setId(Integer.valueOf(12345));
    user.setRegistrationDate(registrationDate);
    user.setActive(Boolean.TRUE);
    user.setMultiValues(new ArrayList<String>(Arrays.asList(new String[] { "TWO", "FOUR" })));
    return user;//from www .  j a  v  a2s.  c o m
}

From source file:com.adobe.acs.commons.http.headers.impl.DailyExpiresHeaderFilterTest.java

@Test
public void testAdjustExpiresFuture() throws Exception {

    Calendar actual = Calendar.getInstance();
    actual.add(Calendar.MINUTE, 1);
    actual.set(Calendar.SECOND, 0);
    actual.set(Calendar.MILLISECOND, 0);

    Calendar expected = Calendar.getInstance();
    expected.setTime(actual.getTime());/*  ww w. java 2s  .c  o m*/

    filter.adjustExpires(actual);

    assertTrue(DateUtils.isSameInstant(expected, actual));
}

From source file:DateUtils.java

public static String getTimestamp() {
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());

    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);
    int hours = cal.get(Calendar.HOUR_OF_DAY);
    // use 24 hour clock
    int minutes = cal.get(Calendar.MINUTE);
    int seconds = cal.get(Calendar.SECOND);
    int milli = cal.get(Calendar.MILLISECOND);

    return "" + year + "-" + month + "-" + day + "_" + formatTime(hours, minutes, seconds, milli);
}

From source file:net.netheos.pcsapi.providers.hubic.SwiftTest.java

@Test
public void testParseTimestamp() {
    // Check we won't break if a header is missing :
    Headers headers = new Headers();
    Date timestamp = Swift.parseTimestamp(headers);
    assertNull(timestamp);// w w w  .  j  a va 2  s  . c  om

    headers.addHeader("X-Timestamp", "1383925113.43900"); // 2013-11-08T16:38:33.439+01:00
    timestamp = Swift.parseTimestamp(headers);

    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(timestamp);
    System.out.println(timestamp);
    assertEquals(2013, cal.get(Calendar.YEAR));
    assertEquals(Calendar.NOVEMBER, cal.get(Calendar.MONTH));
    assertEquals(8, cal.get(Calendar.DAY_OF_MONTH));
    assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
    assertEquals(38, cal.get(Calendar.MINUTE));
    assertEquals(33, cal.get(Calendar.SECOND));
    assertEquals(439, cal.get(Calendar.MILLISECOND));

    checkTimestamp("1383925113.430723", new Date(1383925113430L));
    checkTimestamp("1383925113.43900", new Date(1383925113439L));
    checkTimestamp("1383925113.439", new Date(1383925113439L));
    checkTimestamp("1383925113.43", new Date(1383925113430L));
    checkTimestamp("1383925113.4", new Date(1383925113400L));
    checkTimestamp("1383925113.", new Date(1383925113000L));
    checkTimestamp("1383925113", new Date(1383925113000L));
}

From source file:com.ykun.commons.utils.commons.DateUtils.java

/**
 * //from  w  w  w  . j a v a2 s  .  c  o m
 *
 * @param date
 * @param minuteAmount
 * @return Date
 */
public static Date addMinute(Date date, int minuteAmount) {
    return addInteger(date, Calendar.MINUTE, minuteAmount);
}

From source file:net.audumla.climate.bom.ObserverTest.java

@Test
public void testObservations() {
    Calendar c = GregorianCalendar.getInstance();
    c.setTime(new Date());
    c.set(Calendar.MILLISECOND, 0);
    c.set(Calendar.SECOND, 0);/* www  .ja va  2  s  .  c  o  m*/
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) - 1);
    Date now = c.getTime();
    BOMClimateDataSource source = ClimateDataSourceFactory.newInstance(BOMClimateDataSource.class);
    source.setId("086068");
    ClimateObserver forcaster = new BOMPeriodicClimateObserver(source);
    ClimateData data = forcaster.getClimateData(now);
    Assert.assertEquals(now, data.getTime());
    // Assert.assertNotNull(data.getMinimumTemperature());
    c.set(Calendar.HOUR_OF_DAY, 12);
    Date obTime1 = c.getTime();
    ClimateObservation obs1 = data.getObservation(obTime1, ClimateData.ObservationMatch.CLOSEST);
    Assert.assertNotNull(obs1);
    Assert.assertNotNull(obs1.getTemperature());
    c.set(Calendar.HOUR_OF_DAY, 11);
    Date obTime2 = c.getTime();
    ClimateObservation obs2 = data.getObservation(obTime2, ClimateData.ObservationMatch.CLOSEST);
    Assert.assertNotNull(obs2);
    Assert.assertNotNull(obs2.getTemperature());
    Assert.assertNotSame(obs1.getTime(), obs2.getTime());

}

From source file:eu.cloudwave.wp5.feedbackhandler.repositories.aggregations.AggregatedMicroserviceClientRequest.java

public AggregatedMicroserviceClientRequest(MicroserviceClientRequest msClienReq) {
    this.microserviceClientRequest = msClienReq;

    // set default timestamp aggregation to minute
    this.timestampAggregation = Calendar.MINUTE;
}

From source file:net.chrisrichardson.foodToGo.placeOrderTransactionScripts.dao.RestaurantDAOIBatisImpl.java

public List findAvailableRestaurants(Address deliveryAddress, Date deliveryTime) {
    Calendar c = Calendar.getInstance();
    c.setTime(deliveryTime);/*from  www. j av  a2s  .  co  m*/
    int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    String zipCode = deliveryAddress.getZip();

    Map deliveryInfo = new HashMap();
    deliveryInfo.put("zipCode", zipCode);
    deliveryInfo.put("dayOfWeek", new Integer(dayOfWeek));
    deliveryInfo.put("deliveryTime", hour * 100 + minute);
    return getSqlMapClientTemplate().queryForList("findAvailableRestaurants", deliveryInfo);
}

From source file:helper.lang.DateHelperTest.java

@Test
public void testAsUtcDayDate() {
    Calendar localTime = Calendar.getInstance(TimeZone.getTimeZone("CST"));
    Calendar cal = DateHelper.asUtcDay(localTime.getTime());
    assertEquals(0, cal.get(Calendar.MILLISECOND));
    assertEquals(0, cal.get(Calendar.MINUTE));
    assertEquals(0, cal.get(Calendar.HOUR));
    assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
    assertEquals(DateHelper.UTC_TIME_ZONE, cal.getTimeZone());
    //assertEquals(TimeZone.getTimeZone("CST"), localTime.getTimeZone());
    //assertEquals(localTime.get(Calendar.YEAR), cal.get(Calendar.YEAR));
    //assertEquals(localTime.get(Calendar.MONTH), cal.get(Calendar.MONTH));
    //assertEquals(localTime.get(Calendar.DATE), cal.get(Calendar.DATE));
}