Example usage for java.util Calendar HOUR

List of usage examples for java.util Calendar HOUR

Introduction

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

Prototype

int HOUR

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

Click Source Link

Document

Field number for get and set indicating the hour of the morning or afternoon.

Usage

From source file:uk.org.funcube.fcdw.server.processor.WholeOrbitDataProcessorImpl.java

@Override
@Transactional(readOnly = false)/*from   w  w w.j  a v  a2s.  co  m*/
public void process(long satelliteId) {
    Calendar cal = Calendar.getInstance(TZ);
    cal.add(Calendar.HOUR, -24);

    final List<HexFrameEntity> wodList = hexFrameDao.findUnprocessedWOD(satelliteId, cal.getTime());

    LOG.debug("Found: " + wodList.size() + " unprocessed wod frames");

    long oldSeqNo = -1;

    List<String> frames = new ArrayList<String>();

    List<HexFrameEntity> processedHexFrames = new ArrayList<HexFrameEntity>();

    Date receivedDate = null;

    for (final HexFrameEntity wodFrame : wodList) {
        if (wodFrame.getFrameType() == 11) {
            receivedDate = wodFrame.getCreatedDate();
        }
        if (wodFrame.getSequenceNumber() != oldSeqNo) {
            if (oldSeqNo != -1) {
                if (frames.size() == 12) {

                    cal = Calendar.getInstance(TZ);
                    cal.setTime(receivedDate);
                    cal.set(Calendar.SECOND, 0);
                    cal.set(Calendar.MILLISECOND, 0);
                    receivedDate = cal.getTime();

                    extractAndSaveWod(satelliteId, oldSeqNo, frames, receivedDate);

                    for (HexFrameEntity hfe : processedHexFrames) {
                        hfe.setHighPrecisionProcessed(true);
                        hexFrameDao.save(hfe);
                    }
                }
                frames = new ArrayList<String>();
                processedHexFrames = new ArrayList<HexFrameEntity>();
                frames.add(wodFrame.getHexString().substring(106, wodFrame.getHexString().length()));
                processedHexFrames.add(wodFrame);
            }

            oldSeqNo = wodFrame.getSequenceNumber();
        } else {
            frames.add(wodFrame.getHexString().substring(106, wodFrame.getHexString().length()));
            processedHexFrames.add(wodFrame);
        }
    }

}

From source file:de.hybris.platform.integration.cis.payment.impl.DefaultCisOrderDao.java

/**
 * Find all orders that were placed in Review and have been inactive for more than 12 hours
 *///w ww . j a v  a 2  s.  c o  m
public List<OrderModel> findInactiveOrders() {
    final Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.HOUR, -12);

    final Map<String, Object> queryParams = new HashMap<String, Object>();
    queryParams.put("orderStatus", OrderStatus.SUSPENDED);
    queryParams.put("inactiveDate", calendar.getTime());

    return getFlexibleSearchResult(new FlexibleSearchQuery(FIND_INACTIVE_SUSPENEDED_ORDERS_QUERY, queryParams));
}

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   w  w  w .j  av  a 2  s  . c  o  m
}

From source file:CalendarDemo.java

public void format() {

    // Tell the calendar what date/time to format
    calendar.setTime(timeNow);/*from  ww w  .j  a  v  a  2s. c o m*/

    // print out most of the known fields
    System.out.println("ERA: " + calendar.get(Calendar.ERA));
    System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
    System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
    System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
    System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
    System.out.println("DATE: " + calendar.get(Calendar.DATE));
    System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
    System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
    System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
    System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
    System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
    System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
    System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY));
    System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
    System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
    System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
    System.out.println("ZONE_OFFSET: " + (calendar.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000)));
    System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET) / (60 * 60 * 1000)));
}

From source file:at.irian.demo.jsfatwork.repository.jpa.JpaPollRepository.java

public Poll createNewEntity() {
    Calendar defaultEndDate = Calendar.getInstance();
    defaultEndDate.setTime(new Date());
    defaultEndDate.add(Calendar.HOUR, 72);
    return new Poll(true, new Date(), defaultEndDate.getTime());
}

From source file:com.beligum.core.accounts.UserManager.java

public static void storeCurrentUser(User user) {
    Http.Context.current().session().put(SESSION_KEY_USER, user.getId().toString());
    Calendar timeOut = DateTimeHelper.getCurrentTime();
    timeOut.add(Calendar.HOUR, 1);
    Http.Context.current().session().put(SESSION_KEY_TIMEOUT,
            DateTimeHelper.formatDate(timeOut, "dd/MM/yyyy HH:mm"));
}

From source file:com.linuxbox.enkive.teststats.StatsDayGrainTest.java

@BeforeClass
public static void setUp() throws ParseException, GathererException {
    coll = TestHelper.GetTestCollection();
    client = TestHelper.BuildClient();//from  ww  w.  j a  va 2  s  . co  m
    grain = new DayConsolidator(client);

    List<Map<String, Object>> stats = (new HourConsolidator(client)).consolidateData();
    Map<String, Object> timeMap = new HashMap<String, Object>();
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.MILLISECOND, 0);
    cal.set(Calendar.SECOND, 1);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.HOUR, 0);
    for (int i = 0; i < 10; i++) {
        if (i == 5) {
            cal.add(Calendar.DATE, -1);
        }
        timeMap.put(CONSOLIDATION_MAX, cal.getTime());
        timeMap.put(CONSOLIDATION_MIN, cal.getTime());
        for (Map<String, Object> data : stats) {
            data.put(STAT_TIMESTAMP, timeMap);
        }
        client.storeData(stats);
    }
    dataCount = coll.count();
}

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));
}

From source file:com.linuxbox.enkive.teststats.StatsWeekGrainTest.java

@BeforeClass
public static void setUp() throws ParseException, GathererException {
    coll = TestHelper.GetTestCollection();
    client = TestHelper.BuildClient();//from  ww  w.  j a  va  2  s.  c o  m
    grain = new WeekConsolidator(client);

    List<Map<String, Object>> stats = (new DayConsolidator(client)).consolidateData();
    Map<String, Object> timeMap = createMap();
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.MILLISECOND, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.HOUR, 0);
    for (int i = 0; i < 10; i++) {
        if (i == 5) {
            cal.add(Calendar.WEEK_OF_MONTH, -1);
        }
        timeMap.put(CONSOLIDATION_MAX, cal.getTime());
        timeMap.put(CONSOLIDATION_MIN, cal.getTime());
        for (Map<String, Object> data : stats) {
            data.put(STAT_TIMESTAMP, timeMap);
        }
        client.storeData(stats);
    }
    dataCount = coll.count();
}