List of usage examples for java.util Calendar DAY_OF_YEAR
int DAY_OF_YEAR
To view the source code for java.util Calendar DAY_OF_YEAR.
Click Source Link
get
and set
indicating the day number within the current year. From source file:DateUtils.java
/** * <p>Checks if the first calendar date is before the second calendar date ignoring time.</p> * @param cal1 the first calendar, not altered, not null. * @param cal2 the second calendar, not altered, not null. * @return true if cal1 date is before cal2 date ignoring time. * @throws IllegalArgumentException if either of the calendars are <code>null</code> *///from ww w .ja v a 2 s .c om public static boolean isBeforeDay(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The dates must not be null"); } if (cal1.get(Calendar.ERA) < cal2.get(Calendar.ERA)) return true; if (cal1.get(Calendar.ERA) > cal2.get(Calendar.ERA)) return false; if (cal1.get(Calendar.YEAR) < cal2.get(Calendar.YEAR)) return true; if (cal1.get(Calendar.YEAR) > cal2.get(Calendar.YEAR)) return false; return cal1.get(Calendar.DAY_OF_YEAR) < cal2.get(Calendar.DAY_OF_YEAR); }
From source file:com.dianxin.imessage.common.util.DateUtil.java
/** * //w w w .ja va 2 s.c o m * * @return */ public static int calculateDays() { Calendar cd = Calendar.getInstance(); cd.set(Calendar.DAY_OF_YEAR, 1);// cd.roll(Calendar.DAY_OF_YEAR, -1);// int MaxYear = cd.get(Calendar.DAY_OF_YEAR); return MaxYear; }
From source file:com.autentia.bcbp.elements.MandatoryItemsRepeated.java
public MandatoryItemsRepeated(String operatingCarrierPNRCode, String fromCityAirportCode, String toCityAirportCode, String operatingCarrierDesignator, String flightNumber, Date dateOfFlight, String compartmentCode, String seatNumber, String checkinSequenceNumber, String passengerStatus) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(dateOfFlight);//from w w w . j av a 2 s.c o m this.operatingCarrierPNRCode = new Item(operatingCarrierPNRCode, operatingCarrierPNRCodeLength, 7, PaddingType.String); this.fromCityAirportCode = new Item(fromCityAirportCode, fromCityAirportCodeLength, 26, PaddingType.String); this.toCityAirportCode = new Item(toCityAirportCode, toCityAirportCodeLength, 38, PaddingType.String); this.operatingCarrierDesignator = new Item(operatingCarrierDesignator, operatingCarrierDesignatorLength, 42, PaddingType.String); this.flightNumber = new Item(flightNumber, flightNumberLength, 43, PaddingType.NumberFollowedByAlpha); this.dateOfFlight = new Item(String.valueOf(calendar.get(Calendar.DAY_OF_YEAR)), dateOfFlightLength, 46, PaddingType.Number); this.compartmentCode = new Item(compartmentCode, compartmentCodeLength, 71, PaddingType.String); if (StringUtils.isBlank(seatNumber)) { this.seatNumber = new Item(checkinSequenceNumber, seatNumberLength, 104, PaddingType.Number); } else { this.seatNumber = new Item(seatNumber, seatNumberLength, 104, PaddingType.Number); } this.chekinSequenceNumber = new Item(checkinSequenceNumber, chekinSequenceNumberLength, 107, PaddingType.NumberFollowedByAlpha); this.passengerStatus = new Item(passengerStatus, passengerStatusLength, 113, PaddingType.String); this.variableFieldSize = new Item("00", variableFieldSizeLength, 6, PaddingType.Number); }
From source file:info.joseluismartin.gtc.AbstractTileCache.java
public boolean isTileCached(Tile tile) { File file = new File(getCachePath(tile)); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, -age); if (!file.exists()) { log.info("Tile not found in cache: [" + file.getAbsolutePath() + "]"); } else {// w w w .j a va 2s . c o m log.info("Tile found in cache: [" + file.getAbsolutePath() + "]"); } return file.exists(); // && file.lastModified() < calendar.getTimeInMillis(); }
From source file:com.netflix.genie.core.util.UnixProcessCheckerUnitTests.java
/** * Make sure if the timeout has been exceeded then an exception is thrown indicating the process should be killed. * * @throws GenieTimeoutException on timeout * @throws IOException on any other error *///from w w w . j a va 2 s . c om @Test(expected = GenieTimeoutException.class) public void canCheckProcessTimeout() throws GenieTimeoutException, IOException { final Calendar yesterday = Calendar.getInstance(); yesterday.add(Calendar.DAY_OF_YEAR, -1); this.processChecker = new UnixProcessChecker(PID, this.executor, yesterday.getTime()); this.processChecker.checkProcess(); }
From source file:it.infn.ct.security.utilities.LDAPCleaner.java
private void firstCheck(int days) { _log.info("Search users starting the account extension cycle"); List<LDAPUser> userLst = LDAPUtils.getIdPUserList(); for (LDAPUser user : userLst) { Calendar cal = GregorianCalendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, days); Calendar userCreation = GregorianCalendar.getInstance(); userCreation.setTime(user.getCreationTime()); if (cal.get(Calendar.DAY_OF_YEAR) == userCreation.get(Calendar.DAY_OF_YEAR)) { _log.info("Update account procedure for the user " + user.getGivenname() + " " + user.getSurname() + "(" + user.getUsername() + ") started"); UserConfirmUpdate ucu = new UserConfirmUpdate(user.getUsername(), cal.getTime(), false); Session ses = factory.openSession(); ses.beginTransaction();//from w ww. j a v a 2 s. c o m if (ses.createCriteria(UserConfirmUpdate.class).add(Restrictions.eq("username", user.getUsername())) .add(Restrictions.eq("updated", Boolean.FALSE)).list().isEmpty()) { ses.save(ucu); } ses.getTransaction().commit(); ses.close(); sendUserRemainder(user, days); } } }
From source file:net.morphbank.mbsvc3.mapsheet.MapSpreadsheetToXml.java
private Date dateToPublish() { if (fieldMapper instanceof XlsFieldMapper) { Sheet credentials = ((XlsFieldMapper) fieldMapper).getCredentialSheet(); return credentials.getRow(7).getCell(1).getDateCellValue(); }/*from w ww . j ava 2s . com*/ Calendar nextYear = Calendar.getInstance(); nextYear.add(Calendar.DAY_OF_YEAR, DAYS_TO_PUBLISH); return nextYear.getTime(); }
From source file:eu.cloudscale.showcase.generate.GenerateHibernate.java
@Override public void populateOrdersAndCC_XACTSTable() { GregorianCalendar cal;// w w w .ja v a 2s .c o m String[] credit_cards = { "VISA", "MASTERCARD", "DISCOVER", "AMEX", "DINERS" }; int num_card_types = 5; String[] ship_types = { "AIR", "UPS", "FEDEX", "SHIP", "COURIER", "MAIL" }; int num_ship_types = 6; String[] status_types = { "PROCESSING", "SHIPPED", "PENDING", "DENIED" }; int num_status_types = 4; // Order variables int O_C_ID; java.sql.Timestamp O_DATE; double O_SUB_TOTAL; double O_TAX; double O_TOTAL; String O_SHIP_TYPE; java.sql.Timestamp O_SHIP_DATE; int O_BILL_ADDR_ID, O_SHIP_ADDR_ID; String O_STATUS; String CX_TYPE; int CX_NUM; String CX_NAME; java.sql.Date CX_EXPIRY; String CX_AUTH_ID; int CX_CO_ID; System.out.println("Populating ORDERS, ORDER_LINES, CC_XACTS with " + NUM_ORDERS + " orders"); System.out.print("Complete (in 10,000's): "); Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for (int i = 1; i <= NUM_ORDERS; i++) { if (i % 1000 == 0) { session.flush(); session.clear(); System.out.print(i / 1000 + " "); } if (i % 10000 == 0) { System.out.println(); } int num_items = getRandomInt(1, 5); cal = new GregorianCalendar(); cal.add(Calendar.DAY_OF_YEAR, -1 * getRandomInt(1, 60)); O_DATE = new java.sql.Timestamp(cal.getTime().getTime()); O_SUB_TOTAL = (double) getRandomInt(1000, 999999) / 100; O_TAX = O_SUB_TOTAL * 0.0825; O_TOTAL = O_SUB_TOTAL + O_TAX + 3.00 + num_items; O_SHIP_TYPE = ship_types[getRandomInt(0, num_ship_types - 1)]; cal.add(Calendar.DAY_OF_YEAR, getRandomInt(0, 7)); O_SHIP_DATE = new java.sql.Timestamp(cal.getTime().getTime()); O_STATUS = status_types[getRandomInt(0, num_status_types - 1)]; Orders order = new Orders(); ICustomer customer = this.customers.get(getRandomInt(1, this.customers.size() - 1)); IAddress billAddress = this.addresses.get(getRandomInt(1, this.addresses.size() - 1)); IAddress shipAddress = this.addresses.get(getRandomInt(1, this.addresses.size() - 1)); // int OL_I_ID = getRandomInt( 1, NUM_ITEMS ); // IItem item = itemDao.findById( OL_I_ID ); // Set parameter order.setCustomer(customer); order.setODate(new Date(O_DATE.getTime())); order.setOSubTotal(O_SUB_TOTAL); order.setOTax(O_TAX); order.setOTotal(O_TOTAL); order.setOShipType(O_SHIP_TYPE); order.setOShipDate(O_SHIP_DATE); order.setAddressByOBillAddrId(billAddress); order.setAddressByOShipAddrId(shipAddress); order.setOStatus(O_STATUS); order.setCcXactses(new HashSet<ICcXacts>()); order.setOrderLines(new HashSet<IOrderLine>()); session.save(order); for (int j = 1; j <= num_items; j++) { int OL_ID = j; int OL_O_ID = i; int OL_QTY = getRandomInt(1, 300); double OL_DISCOUNT = (double) getRandomInt(0, 30) / 100; String OL_COMMENTS = getRandomAString(20, 100); OrderLine orderLine = new OrderLine(); orderLine.setItem(this.items.get(getRandomInt(1, this.items.size() - 1))); orderLine.setOlQty(OL_QTY); orderLine.setOlDiscount(OL_DISCOUNT); orderLine.setOlComment(OL_COMMENTS); orderLine.setOrders(order); session.save(orderLine); order.getOrderLines().add(orderLine); } CX_TYPE = credit_cards[getRandomInt(0, num_card_types - 1)]; CX_NUM = getRandomNString(16); CX_NAME = getRandomAString(14, 30); cal = new GregorianCalendar(); cal.add(Calendar.DAY_OF_YEAR, getRandomInt(10, 730)); CX_EXPIRY = new java.sql.Date(cal.getTime().getTime()); CX_AUTH_ID = getRandomAString(15); CcXacts ccXacts = new CcXacts(); ccXacts.setCountry(this.countries.get(getRandomInt(1, this.countries.size() - 1))); ccXacts.setOrders(order); ccXacts.setCxType(CX_TYPE); ccXacts.setCxNum(CX_NUM); ccXacts.setCxName(CX_NAME); ccXacts.setCxExpiry(CX_EXPIRY); ccXacts.setCxAuthId(CX_AUTH_ID); ccXacts.setCxXactAmt(O_TOTAL); ccXacts.setCxXactDate(O_SHIP_DATE); // ccXacts.setOrders( order ); order.getCcXactses().add(ccXacts); session.save(ccXacts); } tx.commit(); session.close(); System.out.println(""); }
From source file:com.brightcove.com.zartan.verifier.video.PlaysReportingVerifier.java
public static boolean isToday(Long uploadDate) { Calendar uploaded = Calendar.getInstance(); uploaded.setTime(new Date(uploadDate)); Calendar now = Calendar.getInstance(); now.setTime(new Date()); return (uploaded.get(Calendar.ERA) == now.get(Calendar.ERA) && uploaded.get(Calendar.YEAR) == now.get(Calendar.YEAR) && uploaded.get(Calendar.DAY_OF_YEAR) == now.get(Calendar.DAY_OF_YEAR)); }