List of usage examples for java.util Calendar DAY_OF_MONTH
int DAY_OF_MONTH
To view the source code for java.util Calendar DAY_OF_MONTH.
Click Source Link
get
and set
indicating the day of the month. From source file:com.webkruscht.wmt.DownloadFiles.java
private static Options getOptions(String[] argv) throws NumberFormatException { int c;//from ww w.ja va 2s .c o m boolean error; Options ret; Calendar cal; SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); ret = new Options(); String arg; LongOpt[] longopts = new LongOpt[3]; // StringBuffer sb = new StringBuffer(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); longopts[1] = new LongOpt("lastmonth", LongOpt.OPTIONAL_ARGUMENT, sb, 'm'); longopts[2] = new LongOpt("days", LongOpt.OPTIONAL_ARGUMENT, sb, 'd'); // Getopt g = new Getopt("DownloadFiles", argv, "", longopts); g.setOpterr(false); // We'll do our own error handling // while ((c = g.getopt()) != -1) switch (c) { case 0: arg = g.getOptarg(); switch ((char) (new Integer(sb.toString())).intValue()) { case 'd': ret.setDays(Integer.parseInt(arg)); case 'm': cal = GregorianCalendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); ret.setEnddate(df.format(cal.getTime())); cal.set(Calendar.DAY_OF_MONTH, 1); ret.setStartdate(df.format(cal.getTime())); } break; } ; return ret; }
From source file:com.u2apple.tool.dao.AndroidDeviceDaoImpl.java
@Override public List<AndroidDeviceRanking> getUnidentifiedDevicesOfRootSpirit(int days) throws IOException, JSchException { SqlSession sqlSession = MyBatisHelper.getRootSqlSessionFactory().openSession(); RootDeviceMapper mapper = sqlSession.getMapper(RootDeviceMapper.class); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, -days); calendar = DateUtils.truncate(calendar, Calendar.DATE); return mapper.selectUnidentifiedDevices(SqlUtils.getMonthlyTable("log_root_solution"), calendar.getTime()); }
From source file:model.service.ServiceEmployee.java
@Transactional(readOnly = true) public List<Temployee> listExpirationLicenses() { Calendar date = Calendar.getInstance(); /* Sumamos 30 dias al dia actual */ date.add(Calendar.DAY_OF_MONTH, 30); Date dateFuture = date.getTime(); List<Temployee> list = daoEmployee.listUpcomingDatesActive("dateLicense", dateFuture); return list;/*w ww. j a v a 2 s . c o m*/ }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * @return A number corresponding to Calendar days in the month *///from w w w . j a v a2s . co m public static int getDay(Date arg) { // Set Calendar Calendar calendar = Calendar.getInstance(); calendar.setTime(arg); return calendar.get(Calendar.DAY_OF_MONTH); }
From source file:de.lemo.apps.application.DateWorkerImpl.java
public int daysBetween(final Calendar startDate, final Calendar endDate) { // TODO a loop seems inefficient for this. Maybe use joda time, it has a `daysBetween` method. // Is the the result correct? - We get '1 day' even if the dates are only seconds apart. final Calendar date = (Calendar) startDate.clone(); int daysBetween = 0; while (date.before(endDate)) { date.add(Calendar.DAY_OF_MONTH, 1); daysBetween++;/* w w w . j a v a2 s. co m*/ } return daysBetween; }
From source file:ru.mystamps.web.service.CronServiceImpl.java
@Override @Scheduled(cron = EVERY_DAY_AT_00_00)//from w w w .j a v a 2 s . co m @Transactional(readOnly = true) public void sendDailyStatistics() { Date today = DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH); Date yesterday = DateUtils.addDays(today, -1); AdminDailyReport report = new AdminDailyReport(); report.setStartDate(yesterday); report.setEndDate(today); report.setAddedCategoriesCounter(categoryService.countAddedSince(yesterday)); report.setAddedCountriesCounter(countryService.countAddedSince(yesterday)); long untranslatedCategories = categoryService.countUntranslatedNamesSince(yesterday); report.setUntranslatedCategoriesCounter(untranslatedCategories); long untranslatedCountries = countryService.countUntranslatedNamesSince(yesterday); report.setUntranslatedCountriesCounter(untranslatedCountries); report.setAddedSeriesCounter(seriesService.countAddedSince(yesterday)); report.setUpdatedSeriesCounter(seriesService.countUpdatedSince(yesterday)); report.setUpdatedCollectionsCounter(collectionService.countUpdatedSince(yesterday)); report.setRegistrationRequestsCounter(usersActivationService.countCreatedSince(yesterday)); report.setRegisteredUsersCounter(userService.countRegisteredSince(yesterday)); long notFoundCounter = suspiciousActivityService.countByTypeSince(SiteServiceImpl.PAGE_NOT_FOUND, yesterday); report.setNotFoundCounter(notFoundCounter); long failedAuthCounter = suspiciousActivityService.countByTypeSince(SiteServiceImpl.AUTHENTICATION_FAILED, yesterday); report.setFailedAuthCounter(failedAuthCounter); long missingCsrfCounter = suspiciousActivityService.countByTypeSince(SiteServiceImpl.MISSING_CSRF_TOKEN, yesterday); report.setMissingCsrfCounter(missingCsrfCounter); long invalidCsrfCounter = suspiciousActivityService.countByTypeSince(SiteServiceImpl.INVALID_CSRF_TOKEN, yesterday); report.setInvalidCsrfCounter(invalidCsrfCounter); mailService.sendDailyStatisticsToAdmin(report); }
From source file:Main.java
private static String doFormatDate(Calendar calendar) { return String.format(Locale.ROOT, "%04d-%02d-%02dT%02d:%02d:%02dZ", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); }
From source file:com.aimdek.ccm.dao.impl.test.CreditCardDaoImplTest.java
/** * initialize.//from www .ja v a 2 s.c om */ @Before public void initialize() { List<CreditCard> creditcardList = new ArrayList<CreditCard>(); CreditCard creditCard = new CreditCard(); creditCard.setAvailableCreditLimit(15000); creditCard.setCardNumber("1234-1234-1234-0008"); creditCard.setCreditLimit(20000); creditCard.setCvv(420); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); creditCard.setLastStatementDate(calendar.getTime()); creditCard.setStatementDate(new Date()); creditCard.setNameOnCard("Test1 Test1"); creditCard.setCardHolderId(1); creditCard.setValidFromDate(new Date()); creditCard.setValidToDate(new Date()); creditCardRepository.saveCreditCard(creditCard); creditCardId = creditCard.getId(); CreditCard creditCard1 = new CreditCard(); creditCard1.setAvailableCreditLimit(15000); creditCard1.setCardNumber("2345-1234-2345-0009"); creditCard1.setCreditLimit(20000); creditCard1.setCvv(420); creditCard1.setLastStatementDate(calendar.getTime()); creditCard1.setStatementDate(new Date()); creditCard1.setNameOnCard("Test2 Test2"); creditCard1.setCardHolderId(2); creditCard1.setValidFromDate(new Date()); creditCard1.setValidToDate(new Date()); creditcardList.add(creditCard1); CreditCard creditCard2 = new CreditCard(); creditCard2.setAvailableCreditLimit(15000); creditCard2.setCardNumber("1234-1234-1234-0010"); creditCard2.setCreditLimit(20000); creditCard2.setCvv(420); creditCard2.setLastStatementDate(calendar.getTime()); creditCard2.setStatementDate(new Date()); creditCard2.setNameOnCard("Test3 Test3"); creditCard2.setCardHolderId(3); creditCard2.setValidFromDate(new Date()); creditCard2.setValidToDate(new Date()); creditcardList.add(creditCard2); CreditCard creditCard3 = new CreditCard(); creditCard3.setAvailableCreditLimit(15000); creditCard3.setCardNumber("2345-1234-2345-0011"); creditCard3.setCreditLimit(20000); creditCard3.setCvv(420); creditCard3.setLastStatementDate(calendar.getTime()); creditCard3.setStatementDate(new Date()); creditCard3.setNameOnCard("Test4 Test4"); creditCard3.setCardHolderId(4); creditCard3.setValidFromDate(new Date()); creditCard3.setValidToDate(new Date()); creditcardList.add(creditCard3); CreditCard creditCard5 = new CreditCard(); creditCard5.setAvailableCreditLimit(15000); creditCard5.setCardNumber("1234-1234-1234-0012"); creditCard5.setCreditLimit(20000); creditCard5.setCvv(420); creditCard5.setLastStatementDate(calendar.getTime()); creditCard5.setStatementDate(new Date()); creditCard5.setNameOnCard("Test3 Test3"); creditCard5.setCardHolderId(4); creditCard5.setValidFromDate(new Date()); creditCard5.setValidToDate(new Date()); creditcardList.add(creditCard5); creditCardRepository.save(creditcardList); }
From source file:br.com.contratempo.controller.ClienteController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView cadastraCliente(@ModelAttribute Cliente cliente, @RequestParam(value = "turmas", required = false) List<Turma> turmas, Model model) { cliente = this.salvaCliente(cliente); for (Turma turma : turmas) { Calendar inicio = Calendar.getInstance(); inicio.set(Calendar.DAY_OF_MONTH, 10); Calendar fim = Calendar.getInstance(); inicio.set(Calendar.DAY_OF_MONTH, 10); inicio.add(Calendar.MONTH, 1); Matricula matricula = new Matricula(); matricula.setCliente(cliente);//from w w w .java 2 s .c o m matricula.setValor(turma.getValorPadrao()); matricula.setDtInicio(inicio); matricula.setDtFim(fim); matricula.setTurma(turma); matriculaRepository.save(matricula); } return new ModelAndView("redirect:/cliente"); }
From source file:org.openehealth.coala.converter.PXSDateConverterTest.java
/** * @throws java.lang.Exception/*from www . j av a 2 s. c o m*/ */ @Before public void setUp() throws Exception { ResourceBundle properties = ResourceBundle.getBundle("coala-document"); longPattern = properties.getString("coala.consent.longdatepattern"); shortPattern = properties.getString("coala.consent.shortdatepattern"); GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR, 3); cal.set(Calendar.MINUTE, 36); cal.set(Calendar.SECOND, 50); cal.set(Calendar.MILLISECOND, 0); referenceDateLong = cal.getTime(); cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); referenceDateShort = cal.getTime(); }