List of usage examples for java.util Calendar DATE
int DATE
To view the source code for java.util Calendar DATE.
Click Source Link
get
and set
indicating the day of the month. From source file:edu.stanford.muse.index.DatedDocument.java
/** invoke only from getHTMLForHeader, needs specific context of date etc. */ private StringBuilder getHTMLForDate() { StringBuilder result = new StringBuilder(); if (date != null) { Calendar c = new GregorianCalendar(); c.setTime(date);/*from www . jav a2s . co m*/ result.append("<tr><td width=\"7%\" align=\"right\" class=\"muted\">Date: </td><td>" + CalendarUtil.getDisplayMonth(c) + " " + c.get(Calendar.DATE) + ", " + c.get(Calendar.YEAR)); } return result; }
From source file:be.fedict.eid.pkira.blm.model.reporting.ReportEntryListQuery.java
private void setQueryParameters(Query query) { Calendar calendar = new GregorianCalendar(); calendar.setTime(reportDate);//w w w . j a v a 2 s. c o m calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Date start = calendar.getTime(); calendar.add(Calendar.DATE, 1); Date end = calendar.getTime(); query.setParameter("start", start, TemporalType.TIMESTAMP); query.setParameter("end", end, TemporalType.TIMESTAMP); if (contractTypeFilter != null) query.setParameter("contractType", contractTypeFilter); if (StringUtils.isNotBlank(certificateDomainNameFilter)) query.setParameter("certificateDomainName", "%" + certificateDomainNameFilter.toLowerCase() + "%"); if (StringUtils.isNotBlank(subjectFilter)) query.setParameter("subject", "%" + subjectFilter.toLowerCase() + "%"); if (successFilter != null) query.setParameter("success", successFilter); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.accounts.UserAccountsPage.java
protected Date figureExpirationDate() { Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, DAYS_TO_USE_PASSWORD_LINK); return c.getTime(); }
From source file:com.salesmanager.core.util.FileUtil.java
public static String getOrderDownloadFileUrl(Order order, Customer customer) throws Exception { Configuration conf = PropertiesUtil.getConfiguration(); MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService); MerchantStore store = mservice.getMerchantStore(order.getMerchantId()); // ***build fileid*** StringBuffer urlconstruct = new StringBuffer(); StringBuffer downloadurl = new StringBuffer(); Calendar endDate = Calendar.getInstance(); endDate.add(Calendar.DATE, conf.getInt("core.product.file.downloadmaxdays", 2)); // add 2 days Date denddate = endDate.getTime(); String sedate = DateUtil.formatDate(denddate); // order id and, expiration date and language urlconstruct.append(order.getOrderId()).append("|").append("|").append(sedate); String lang = conf.getString("core.system.defaultlanguage", "en"); if (customer != null) { lang = customer.getCustomerLang(); }//from w w w . j a v a 2 s . co m String file = EncryptionUtil.encrypt(EncryptionUtil.generatekey(SecurityConstants.idConstant), urlconstruct.toString()); downloadurl.append(ReferenceUtil.buildCheckoutUri(store)) .append(conf.getString("core.salesmanager.core.viewFilesAction")).append("?fileId=").append(file) .append("&lang=").append(lang); return downloadurl.toString(); }
From source file:gr.abiss.calipso.model.dto.ReportDataSet.java
protected void initDefaults(Date dateFrom, Date dateTo, TimeUnit timeUnit, Map<String, Integer> keyIndexes, Map<String, Number> defaultDataEntry) { // init default record values, to be used in missing date slots to ensure regular records if (defaultDataEntry == null) { defaultDataEntry = new HashMap<String, Number>(); for (String key : keyIndexes.keySet()) { defaultDataEntry.put(key, new Integer(0)); }/* w ww . j a v a2 s . c o m*/ } // init default values for all dates in range to ensure regular records Calendar start = Calendar.getInstance(); // get start of day start.setTime(DateUtils.truncate(dateFrom, Calendar.DATE)); Calendar end = Calendar.getInstance(); // get end of day end.setTime(DateUtils.addMilliseconds(DateUtils.ceiling(dateTo, Calendar.DATE), -1)); for (Date date = start.getTime(); start.before(end); start.add(timeUnit.toCalendarUnit(), 1), date = start.getTime()) { this.addEntry(date, defaultDataEntry); } }
From source file:fragment.web.AbstractCampaignPromotionsControllerTest.java
private CampaignPromotion generateCampaignPromotion(int days, boolean trial, boolean fixedAmount, boolean percentage) { CampaignPromotion campaignProm = new CampaignPromotion(); if (fixedAmount) { campaignProm.setDiscountType(DiscountType.FIXED_AMOUNT); }/*from w w w . ja v a 2s . c om*/ if (percentage) { campaignProm.setDiscountType(DiscountType.PERCENTAGE); campaignProm.setPercentOff(BigDecimal.TEN); } campaignProm.setCode("NewCamp"); campaignProm.setTitle("New"); campaignProm.setCreateBy(getPortalUser()); campaignProm.setUpdateBy(getPortalUser()); campaignProm.setCreateDate(new Date()); int noOfdays = days; Calendar createdAt = Calendar.getInstance(); createdAt.add(Calendar.DATE, 0 - noOfdays); campaignProm.setStartDate(createdAt.getTime()); campaignProm.setTrial(trial); return campaignProm; }
From source file:com.autodomum.core.event.EventComponent.java
/** * Update the event context with correct parameters *///from www . j a v a 2s.c om public void updateEventContext() { final Date now = this.getNow(); final Calendar tomorrowCalendar = this.getCalendar(); tomorrowCalendar.setTime(now); this.eventContext.setHoliday(holiday.isHoliday(tomorrowCalendar)); this.eventContext.setHour(tomorrowCalendar.get(Calendar.HOUR_OF_DAY)); this.eventContext.setMinute(tomorrowCalendar.get(Calendar.MINUTE)); tomorrowCalendar.add(Calendar.DATE, 1); final Date tomorrow = tomorrowCalendar.getTime(); final Date sunrise = this.daylight.sunrise(eventContext.getCoordinate(), now); final Date sunset = this.daylight.sunset(eventContext.getCoordinate(), now); final Date sunriseTomorrow = this.daylight.sunrise(eventContext.getCoordinate(), tomorrow); final Date sunsetTomorrow = this.daylight.sunset(eventContext.getCoordinate(), tomorrow); boolean newDaylight = false; if (now.after(sunset)) { newDaylight = false; this.eventContext.setNextSunrise(sunriseTomorrow.getTime()); this.eventContext.setNextSunset(sunsetTomorrow.getTime()); } else if (now.after(sunrise)) { newDaylight = true; this.eventContext.setNextSunrise(sunriseTomorrow.getTime()); this.eventContext.setNextSunset(sunset.getTime()); } else { this.eventContext.setNextSunrise(sunrise.getTime()); this.eventContext.setNextSunset(sunset.getTime()); } if (newDaylight != this.eventContext.isDaylight()) { this.eventContext.setDaylight(newDaylight); if (newDaylight) { this.publish(new SunriseEvent()); } else { this.publish(new SunsetEvent()); } } }
From source file:fitnesse.responders.files.FileResponderTest.java
@Test public void test304IfNotModified() throws Exception { Locale.setDefault(Locale.US); Calendar now = new GregorianCalendar(); now.add(Calendar.DATE, -1); String yesterday = SimpleResponse.makeStandardHttpDateFormat().format(now.getTime()); now.add(Calendar.DATE, 2);/*from w w w .j a v a2s .c o m*/ String tomorrow = SimpleResponse.makeStandardHttpDateFormat().format(now.getTime()); request.setResource("files/testFile1"); request.addHeader("If-Modified-Since", yesterday); responder = (FileResponder) FileResponder.makeResponder(request, SampleFileUtility.base); response = responder.makeResponse(context, request); assertEquals(200, response.getStatus()); request.setResource("files/testFile1"); request.addHeader("If-Modified-Since", tomorrow); responder = (FileResponder) FileResponder.makeResponder(request, SampleFileUtility.base); SimpleResponse notModifiedResponse = (SimpleResponse) responder.makeResponse(context, request); assertEquals(304, notModifiedResponse.getStatus()); assertEquals("", notModifiedResponse.getContent()); assertMatches(HTTP_DATE_REGEXP, notModifiedResponse.getHeader("Date")); assertNotNull(notModifiedResponse.getHeader("Cache-Control")); }
From source file:Main.java
private static Date getEasterDay(int year) { int a = year % 19; int b = year / 100; int c = year % 100; int d = b / 4; int e = b % 4; int f = (b + 8) / 25; int g = (b - f + 1) / 3; int h = ((19 * a) + b - d - g + 15) % 30; int i = c / 4; int k = c % 4; int l = (32 + (2 * e) + (2 * i) - h - k) % 7; int m = (a + (11 * h) + (22 * l)) / 451; int n = (h + l - (7 * m) + 114) / 31; // This is the month number. int p = (h + l - (7 * m) + 114) % 31; // This is the date minus one. Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, n - 1); cal.set(Calendar.DATE, p + 1); return cal.getTime(); }
From source file:br.com.nordestefomento.jrimum.utilix.BancoUtil.java
/** * <p>//from w w w . jav a 2 s . c o m * Calcula o fator de vencimento a partir da subtrao entre a DATA DE * VENCIMENTO de um ttulo e a DATA BASE fixada em 07/10/1997. * </p> * * <p> * O fator de vencimento nada mais que um referencial numrico de 4 * dgitos que representa a quantidade de dias decorridos desde a data base * (07/10/1997) at a data de vencimento do ttulo. Ou seja, a diferena em * dias entre duas datas. * </p> * * <p> * Exemplos: * </p> * <ul type="circule"> <li>07/10/1997 (Fator = 0);</li> <li>03/07/2000 * (Fator = 1000);</li> <li>05/07/2000 (Fator = 1002);</li> <li>01/05/2002 * (Fator = 1667);</li> <li>21/02/2025 (Fator = 9999).</li> </ul> * * <p> * Funcionamento: * </p> * * <ul type="square"> <li>Caso a data de vencimento seja anterior a data * base (Teoricamente fator negativo), uma exceo do tipo * IllegalArgumentException ser lanada.</li> <li>A data limite para o * clculo do fator de vencimento 21/02/2025 (Fator de vencimento = 9999). * Caso a data de vencimento seja posterior a data limite, uma exceo do * tipo IllegalArgumentException ser lanada.</li> </ul> * * <p> * <strong>ATENO</strong>, esse clculo se refere a ttulos em cobrana, * ou melhor: BOLETOS. Desta forma, lembramos que a DATA BASE uma norma da * FEBRABAN. Essa norma diz que todos os boletos emitidos a partir de 1 de * setembro de 2000 (primeiro dia til = 03/07/2000 - SEGUNDA) devem seguir * esta regra de clculo para compor a informao de vencimento no cdigo de * barras. Portanto, boletos no padro FEBRABAN quando capturados por * sistemas da rede bancria permitem que se possa realizar a operao * inversa, ou seja, adicionar data base o fator de vencimento capturado. * Obtendo ento a data de vencimento deste boleto. * </p> * * @param dataVencimento * data de vencimento de um ttulo * @return fator de vencimento calculado * @throws IllegalArgumentException * * @since 0.2 */ public static int calculceFatorDeVencimento(Date dataVencimento) throws IllegalArgumentException { Date dataVencTruncada = null; int fator; if (isNull(dataVencimento)) { throw new IllegalArgumentException( "Impossvel realizar o clculo do fator" + " de vencimento de uma data nula."); } else { dataVencTruncada = DateUtils.truncate(dataVencimento, Calendar.DATE); if (dataVencTruncada.before(DATA_BASE_DO_FATOR_DE_VENCIMENTO) || dataVencTruncada.after(DATA_LIMITE_DO_FATOR_DE_VENCIMENTO)) { throw new IllegalArgumentException( "Para o clculo do fator de" + " vencimento se faz necessrio informar uma data entre" + " " + DateUtil.FORMAT_DD_MM_YYYY.format(DATA_BASE_DO_FATOR_DE_VENCIMENTO) + " e " + DateUtil.FORMAT_DD_MM_YYYY.format(DATA_LIMITE_DO_FATOR_DE_VENCIMENTO)); } else { fator = (int) DateUtil.calculeDiferencaEmDias(DATA_BASE_DO_FATOR_DE_VENCIMENTO, dataVencTruncada); } } return fator; }