List of usage examples for org.joda.time DateTime dayOfMonth
public Property dayOfMonth()
From source file:bo.com.edusoft.basic.Util.java
public static Integer getLastDayOfMonth(Integer month, Integer year) { write("MainApp:getLastDayOfMonth(month[" + month + "],year[" + year + "])"); //Integer currentMonth = getCurrentMonth(); //Integer year = 2017; DateTime currentMonthYear = new DateTime(year, month, 1, 0, 0, 0, 0); write("currentMonthYear[" + currentMonthYear + "]"); write(String.valueOf(currentMonthYear.dayOfMonth().getDateTime().getDayOfMonth())); return currentMonthYear.dayOfMonth().withMaximumValue().dayOfMonth().get(); }
From source file:br.com.nerv.eva.service.listener.ProcessSellDeposit.java
@Transactional public void listen(@Observes @Sell PropertyCustomer pc) { final String value = format(pc.getProperty().getValue()); if (!value.equals(format(pc.getDepositValue()))) { throw new BusinessException("O valor do depsito no corresponde " + "ao valor anunciado"); }// ww w. j a v a2 s .c o m DateTime dt = new DateTime(); if (dt.dayOfMonth().get() <= pc.getPaymentDay()) dt.plusMonths(1); PaymentRegister payment = build(pc); payment.setDate(dt.dayOfMonth().setCopy(pc.getPaymentDay()).toDate()); prDAO.save(payment); }
From source file:ca.farrelltonsolar.classic.CalendarAdapter.java
License:Apache License
public void refreshDays(DateTime month) { this.month = month; // clear items items.clear();//from ww w . j a v a 2s. co m lastDayOfMonth = month.dayOfMonth().withMaximumValue().getDayOfMonth(); firstDayOfFirstWeek = month.getDayOfWeek(); // figure size of the array if (firstDayOfFirstWeek == 0) { days = new String[lastDayOfMonth]; } else { days = new String[lastDayOfMonth + firstDayOfFirstWeek]; } // populate empty days before first real day if (firstDayOfFirstWeek > 0) { for (int j = 0; j < firstDayOfFirstWeek; j++) { days[j] = ""; } } // populate days int dayNumber = 1; for (int i = firstDayOfFirstWeek; i < days.length; i++) { days[i] = "" + dayNumber; dayNumber++; } }
From source file:ch.icclab.cyclops.usecases.tnova.model.TnovaBillingModel.java
License:Open Source License
/** * Just a quick method to get number of days for the month * @param year//w ww . jav a2 s . c o m * @param month * @return */ private static int secondsInMonth(int year, int month) { DateTime dateTime = new DateTime(year, month, 14, 12, 0, 0, 000); Integer days = dateTime.dayOfMonth().getMaximumValue(); return days * 24 * 60 * 60; }
From source file:co.bluepass.web.rest.ClubResource.java
/** * Gets customers by club id.//from w w w . j a va 2 s. c o m * * @param id the id * @param yearMonth the year month * @param response the response * @return the customers by club id * @throws URISyntaxException the uri syntax exception */ @RequestMapping(value = "/clubs/{id}/customers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<List<User>> getCustomersByClubId(@PathVariable Long id, @RequestParam String yearMonth, HttpServletResponse response) throws URISyntaxException { log.debug("REST request to get Actions by club id : {}", id); List<User> users = new ArrayList<User>(); List<ReservationHistory> reservationHistories = null; if (StringUtils.isNotEmpty(yearMonth)) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyMM"); DateTime monthStartDate = formatter.parseDateTime(yearMonth); DateTime monthEndDate = monthStartDate.dayOfMonth().withMaximumValue(); monthEndDate = monthEndDate.withTime(23, 59, 59, 59); reservationHistories = reservationHistoryRepository.findByClubIdAndUsedAndStartTimeBetween(id, true, monthStartDate, monthEndDate); } else { reservationHistories = reservationHistoryRepository.findByClubIdAndUsed(id, true); } if (reservationHistories == null || reservationHistories.isEmpty()) { return new ResponseEntity<List<User>>(users, HttpStatus.OK); } Set<Long> userIds = new HashSet<>(); for (ReservationHistory history : reservationHistories) { userIds.add(history.getUserId()); } users = userRepository.findAll(userIds); return new ResponseEntity<List<User>>(users, HttpStatus.OK); }
From source file:co.propack.sample.vendor.nullPaymentGateway.web.controller.NullPaymentGatewayProcessorController.java
License:Apache License
@RequestMapping(value = "/null-checkout/process", method = RequestMethod.POST) public @ResponseBody String processTransparentRedirectForm(HttpServletRequest request) { Map<String, String[]> paramMap = request.getParameterMap(); String transactionAmount = ""; String orderId = ""; String billingFirstName = ""; String billingLastName = ""; String billingAddressLine1 = ""; String billingAddressLine2 = ""; String billingCity = ""; String billingState = ""; String billingZip = ""; String billingCountry = ""; String shippingFirstName = ""; String shippingLastName = ""; String shippingAddressLine1 = ""; String shippingAddressLine2 = ""; String shippingCity = ""; String shippingState = ""; String shippingZip = ""; String shippingCountry = ""; String creditCardName = ""; String creditCardNumber = ""; String creditCardExpDate = ""; String creditCardCVV = ""; String cardType = "UNKNOWN"; String resultMessage = ""; String resultSuccess = ""; String gatewayTransactionId = UUID.randomUUID().toString(); if (paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT) != null && paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT).length > 0) { transactionAmount = paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT)[0]; }/*w ww. j ava 2s . c om*/ if (paramMap.get(NullPaymentGatewayConstants.ORDER_ID) != null && paramMap.get(NullPaymentGatewayConstants.ORDER_ID).length > 0) { orderId = paramMap.get(NullPaymentGatewayConstants.ORDER_ID)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME).length > 0) { billingFirstName = paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME).length > 0) { billingLastName = paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1).length > 0) { billingAddressLine1 = paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2).length > 0) { billingAddressLine2 = paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_CITY) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_CITY).length > 0) { billingCity = paramMap.get(NullPaymentGatewayConstants.BILLING_CITY)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_STATE) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_STATE).length > 0) { billingState = paramMap.get(NullPaymentGatewayConstants.BILLING_STATE)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP).length > 0) { billingZip = paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP)[0]; } if (paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY) != null && paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY).length > 0) { billingCountry = paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME).length > 0) { shippingFirstName = paramMap.get(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_LAST_NAME) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_LAST_NAME).length > 0) { shippingLastName = paramMap.get(NullPaymentGatewayConstants.SHIPPING_LAST_NAME)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1).length > 0) { shippingAddressLine1 = paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2).length > 0) { shippingAddressLine2 = paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_CITY) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_CITY).length > 0) { shippingCity = paramMap.get(NullPaymentGatewayConstants.SHIPPING_CITY)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_STATE) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_STATE).length > 0) { shippingState = paramMap.get(NullPaymentGatewayConstants.SHIPPING_STATE)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_ZIP) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_ZIP).length > 0) { shippingZip = paramMap.get(NullPaymentGatewayConstants.SHIPPING_ZIP)[0]; } if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_COUNTRY) != null && paramMap.get(NullPaymentGatewayConstants.SHIPPING_COUNTRY).length > 0) { shippingCountry = paramMap.get(NullPaymentGatewayConstants.SHIPPING_COUNTRY)[0]; } if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME) != null && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME).length > 0) { creditCardName = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME)[0]; } if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NUMBER) != null && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NUMBER).length > 0) { creditCardNumber = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NUMBER)[0]; } if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE) != null && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE).length > 0) { creditCardExpDate = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE)[0]; } if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_CVV) != null && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_CVV).length > 0) { creditCardCVV = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_CVV)[0]; } CreditCardValidator visaValidator = new CreditCardValidator(CreditCardValidator.VISA); CreditCardValidator amexValidator = new CreditCardValidator(CreditCardValidator.AMEX); CreditCardValidator mcValidator = new CreditCardValidator(CreditCardValidator.MASTERCARD); CreditCardValidator discoverValidator = new CreditCardValidator(CreditCardValidator.DISCOVER); if (StringUtils.isNotBlank(transactionAmount) && StringUtils.isNotBlank(creditCardNumber) && StringUtils.isNotBlank(creditCardExpDate)) { boolean validCard = false; if (visaValidator.isValid(creditCardNumber)) { validCard = true; cardType = "VISA"; } else if (amexValidator.isValid(creditCardNumber)) { validCard = true; cardType = "AMEX"; } else if (mcValidator.isValid(creditCardNumber)) { validCard = true; cardType = "MASTERCARD"; } else if (discoverValidator.isValid(creditCardNumber)) { validCard = true; cardType = "DISCOVER"; } boolean validDateFormat = false; boolean validDate = false; String[] parsedDate = creditCardExpDate.split("/"); if (parsedDate.length == 2) { String expMonth = parsedDate[0]; String expYear = parsedDate[1]; try { DateTime expirationDate = new DateTime(Integer.parseInt("20" + expYear), Integer.parseInt(expMonth), 1, 0, 0); expirationDate = expirationDate.dayOfMonth().withMaximumValue(); validDate = expirationDate.isAfterNow(); validDateFormat = true; } catch (Exception e) { //invalid date format } } if (!validDate || !validDateFormat) { transactionAmount = "0"; resultMessage = "cart.payment.expiration.invalid"; resultSuccess = "false"; } else if (!validCard) { transactionAmount = "0"; resultMessage = "cart.payment.card.invalid"; resultSuccess = "false"; } else { resultMessage = "Success!"; resultSuccess = "true"; } } else { transactionAmount = "0"; resultMessage = "cart.payment.invalid"; resultSuccess = "false"; } StringBuffer response = new StringBuffer(); response.append("<!DOCTYPE HTML>"); response.append("<!--[if lt IE 7]> <html class=\"no-js lt-ie9 lt-ie8 lt-ie7\" lang=\"en\"> <![endif]-->"); response.append("<!--[if IE 7]> <html class=\"no-js lt-ie9 lt-ie8\" lang=\"en\"> <![endif]-->"); response.append("<!--[if IE 8]> <html class=\"no-js lt-ie9\" lang=\"en\"> <![endif]-->"); response.append("<!--[if gt IE 8]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->"); response.append("<body>"); response.append("<form action=\"" + paymentGatewayConfiguration.getTransparentRedirectReturnUrl() + "\" method=\"POST\" id=\"NullPaymentGatewayRedirectForm\" name=\"NullPaymentGatewayRedirectForm\">"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.TRANSACTION_AMT + "\" value=\"" + transactionAmount + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.ORDER_ID + "\" value=\"" + orderId + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.GATEWAY_TRANSACTION_ID + "\" value=\"" + gatewayTransactionId + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.RESULT_MESSAGE + "\" value=\"" + resultMessage + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.RESULT_SUCCESS + "\" value=\"" + resultSuccess + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_FIRST_NAME + "\" value=\"" + billingFirstName + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_LAST_NAME + "\" value=\"" + billingLastName + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1 + "\" value=\"" + billingAddressLine1 + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2 + "\" value=\"" + billingAddressLine2 + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_CITY + "\" value=\"" + billingCity + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_STATE + "\" value=\"" + billingState + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_ZIP + "\" value=\"" + billingZip + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_COUNTRY + "\" value=\"" + billingCountry + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_FIRST_NAME + "\" value=\"" + shippingFirstName + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_LAST_NAME + "\" value=\"" + shippingLastName + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1 + "\" value=\"" + shippingAddressLine1 + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2 + "\" value=\"" + shippingAddressLine2 + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_CITY + "\" value=\"" + shippingCity + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_STATE + "\" value=\"" + shippingState + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_ZIP + "\" value=\"" + shippingZip + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_COUNTRY + "\" value=\"" + shippingCountry + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_NAME + "\" value=\"" + creditCardName + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_LAST_FOUR + "\" value=\"" + StringUtils.right(creditCardNumber, 4) + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_TYPE + "\" value=\"" + cardType + "\"/>"); response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE + "\" value=\"" + creditCardExpDate + "\"/>"); response.append("<input type=\"submit\" value=\"Please Click Here To Complete Checkout\"/>"); response.append("</form>"); response.append("<script type=\"text/javascript\">"); response.append("document.getElementById('NullPaymentGatewayRedirectForm').submit();"); response.append("</script>"); response.append("</body>"); response.append("</html>"); return response.toString(); }
From source file:com.addthis.hydra.task.source.AbstractPersistentStreamSource.java
License:Apache License
/** */ private String replaceDateElements(DateTime time, String template) { template = template.replace("{YY}", time.year().getAsString()); template = template.replace("{Y}", getTwoDigit(time.year().get())); template = template.replace("{M}", getTwoDigit(time.monthOfYear().get())); template = template.replace("{D}", getTwoDigit(time.dayOfMonth().get())); template = template.replace("{H}", getTwoDigit(time.hourOfDay().get())); if (log.isDebugEnabled()) { log.debug("template=" + template); }/* w w w. j ava 2s. c o m*/ return template; }
From source file:com.chiorichan.plugin.lua.api.OSAPI.java
License:Mozilla Public License
@Override void initialize() { // Push a couple of functions that override original Lua API functions or // that add new functionality to it. lua.getGlobal("os"); // Custom os.clock() implementation returning the time the computer has // been actively running, instead of the native library... lua.pushJavaFunction(new JavaFunction() { @Override//from w ww. j a v a2 s . c om public int invoke(LuaState lua) { lua.pushNumber(System.currentTimeMillis()); return 1; } }); lua.setField(-2, "clock"); lua.pushJavaFunction(new JavaFunction() { @Override public int invoke(LuaState lua) { String format = lua.getTop() > 0 && lua.isString(1) ? lua.toString(1) : "%d/%m/%y %H:%M:%S"; long time = (long) (lua.getTop() > 1 && lua.isNumber(2) ? lua.toNumber(2) * 1000 / 60 / 60 : System.currentTimeMillis()); DateTime dt = new DateTime(time); if (format == "*t") { lua.newTable(0, 8); lua.pushInteger(dt.year().get()); lua.setField(-2, "year"); lua.pushInteger(dt.monthOfYear().get()); lua.setField(-2, "month"); lua.pushInteger(dt.dayOfMonth().get()); lua.setField(-2, "day"); lua.pushInteger(dt.hourOfDay().get()); lua.setField(-2, "hour"); lua.pushInteger(dt.minuteOfHour().get()); lua.setField(-2, "min"); lua.pushInteger(dt.secondOfMinute().get()); lua.setField(-2, "sec"); lua.pushInteger(dt.dayOfWeek().get()); lua.setField(-2, "wday"); lua.pushInteger(dt.dayOfYear().get()); lua.setField(-2, "yday"); } else lua.pushString(dt.toString(DateTimeFormat.forPattern(format))); return 1; } }); lua.setField(-2, "date"); /* * // Date formatting function. * lua.pushScalaFunction(lua => { * val format = * if (lua.getTop > 0 && lua.isString(1)) lua.toString(1) * else "%d/%m/%y %H:%M:%S" * val time = * if (lua.getTop > 1 && lua.isNumber(2)) lua.toNumber(2) * 1000 / 60 / 60 * else machine.worldTime + 5000 * * val dt = GameTimeFormatter.parse(time) * def fmt(format: String) { * if (format == "*t") { * lua.newTable(0, 8) * lua.pushInteger(dt.year) * lua.setField(-2, "year") * lua.pushInteger(dt.month) * lua.setField(-2, "month") * lua.pushInteger(dt.day) * lua.setField(-2, "day") * lua.pushInteger(dt.hour) * lua.setField(-2, "hour") * lua.pushInteger(dt.minute) * lua.setField(-2, "min") * lua.pushInteger(dt.second) * lua.setField(-2, "sec") * lua.pushInteger(dt.weekDay) * lua.setField(-2, "wday") * lua.pushInteger(dt.yearDay) * lua.setField(-2, "yday") * } * else { * lua.pushString(GameTimeFormatter.format(format, dt)) * } * } * * // Just ignore the allowed leading '!', Minecraft has no time zones... * if (format.startsWith("!")) * fmt(format.substring(1)) * else * fmt(format) * 1 * }) * lua.setField(-2, "date") * * // Return ingame time for os.time(). * lua.pushScalaFunction(lua => { * if (lua.isNoneOrNil(1)) { * // Game time is in ticks, so that each day has 24000 ticks, meaning * // one hour is game time divided by one thousand. Also, Minecraft * // starts days at 6 o'clock, versus the 1 o'clock of timestamps so we * // add those five hours. Thus: * // timestamp = (time + 5000) * 60[kh] * 60[km] / 1000[s] * lua.pushNumber((machine.worldTime + 5000) * 60 * 60 / 1000) * } * else { * def getField(key: String, d: Int) = { * lua.getField(-1, key) * val res = lua.toIntegerX(-1) * lua.pop(1) * if (res == null) * if (d < 0) throw new Exception("field '" + key + "' missing in date table") * else d * else res: Int * } * * lua.checkType(1, LuaType.TABLE) * lua.setTop(1) * * val sec = getField("sec", 0) * val min = getField("min", 0) * val hour = getField("hour", 12) * val mday = getField("day", -1) * val mon = getField("month", -1) * val year = getField("year", -1) * * GameTimeFormatter.mktime(year, mon, mday, hour, min, sec) match { * case Some(time) => lua.pushNumber(time) * case _ => lua.pushNil() * } * } * 1 * }) * lua.setField(-2, "time") */ // Pop the os table. lua.pop(1); }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Checks if is last date./*from ww w .j a v a2s.co m*/ * * @return true, if is last date */ public static boolean isLastDate() { DateTime startDate = new DateTime(DateTimeZone.UTC); int max = startDate.dayOfMonth().getMaximumValue(); int current = startDate.getDayOfMonth(); return current == max; }
From source file:com.cronutils.model.time.ExecutionTime.java
License:Apache License
private List<Integer> generateDayCandidatesQuestionMarkNotSupported(int year, int month, WeekDay mondayDoWValue) {//from w w w.ja v a 2s. com DateTime date = new DateTime(year, month, 1, 1, 1); Set<Integer> candidates = Sets.newHashSet(); if (daysOfMonthCronField.getExpression() instanceof Always && daysOfWeekCronField.getExpression() instanceof Always) { candidates.addAll(FieldValueGeneratorFactory .createDayOfMonthValueGeneratorInstance(daysOfMonthCronField, year, month) .generateCandidates(1, date.dayOfMonth().getMaximumValue())); } else { if (daysOfMonthCronField.getExpression() instanceof Always) { candidates.addAll(FieldValueGeneratorFactory .createDayOfWeekValueGeneratorInstance(daysOfWeekCronField, year, month, mondayDoWValue) .generateCandidates(1, date.dayOfMonth().getMaximumValue())); } else { if (daysOfWeekCronField.getExpression() instanceof Always) { candidates.addAll(FieldValueGeneratorFactory .createDayOfMonthValueGeneratorInstance(daysOfMonthCronField, year, month) .generateCandidates(1, date.dayOfMonth().getMaximumValue())); } else { candidates.addAll(FieldValueGeneratorFactory .createDayOfWeekValueGeneratorInstance(daysOfWeekCronField, year, month, mondayDoWValue) .generateCandidates(1, date.dayOfMonth().getMaximumValue())); candidates.addAll(FieldValueGeneratorFactory .createDayOfMonthValueGeneratorInstance(daysOfMonthCronField, year, month) .generateCandidates(1, date.dayOfMonth().getMaximumValue())); } } } List<Integer> candidatesList = Lists.newArrayList(candidates); Collections.sort(candidatesList); return candidatesList; }