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:com.adaptris.core.fs.OlderThanTest.java
@Test public void testAbsolute() throws Exception { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, +1); OlderThan filter = new OlderThan("" + c.getTime().getTime()); File file = writeFile(TempFileUtils.createTrackedFile(filter)); assertTrue(filter.accept(file));//from ww w . j a v a 2 s. c o m }
From source file:edu.northwestern.bioinformatics.studycalendar.web.subject.ScheduleDay.java
public String getDetailTimelineClasses() { Calendar queriableDate = Calendar.getInstance(); queriableDate.setTime(getDate());//ww w .j a v a 2 s. c om List<String> classes = new ArrayList<String>(6); classes.add("day"); classes.add(dateClass(getDate())); if (queriableDate.get(Calendar.DAY_OF_MONTH) == 1) classes.add("month-start"); if (queriableDate.get(Calendar.DAY_OF_YEAR) == 1) classes.add("year-start"); if (isToday()) classes.add("today"); if (!isEmpty()) classes.add("has-activities"); return StringUtils.join(classes.iterator(), ' '); }
From source file:com.mxep.web.common.persistence.SearchFilter.java
/** * searchParamskey?OPERATOR_FIELDNAME//from w ww . j a va2s. co m */ public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) { Map<String, SearchFilter> filters = Maps.newHashMap(); for (Entry<String, Object> entry : searchParams.entrySet()) { // String key = entry.getKey(); Object value = entry.getValue(); if (value != null && StringUtils.isBlank(value.toString())) { continue; } // operatorfiledAttribute String[] names = StringUtils.split(key, "_"); if (names.length < 2) { throw new IllegalArgumentException(key + " is not a valid search filter name"); } String filedName = ""; for (int i = 1; i < names.length; i++) { filedName += names[i]; if ((i + 1) < names.length) { filedName += "."; } } Operator operator = getOperator(names[0]); if (null == operator) { continue; } // searchFilter if (isValidDate(value.toString())) { try { Date date = DateUtils.parseDate((String) value, "yyyy-MM-dd"); // ? if (operator.equals(Operator.LT) || operator.equals(Operator.LTE)) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DAY_OF_YEAR, 1); date = cal.getTime(); } // ???? if (operator.equals(Operator.GT) || operator.equals(Operator.GTE)) { Calendar cal = Calendar.getInstance(); cal.setTime(date); date = cal.getTime(); } value = date; } catch (Exception e) { e.printStackTrace(); } } else if (isValidDateTime(value.toString())) { try { Date date = DateUtils.parseDate((String) value, "yyyy-MM-dd HH:mm:ss"); value = date; } catch (Exception e) { e.printStackTrace(); } } // searchFilter SearchFilter filter = new SearchFilter(filedName, operator, value); filters.put(key, filter); } return filters; }
From source file:it.geosolutions.tools.io.file.FileRemover.java
public static List<File> collectOlder(final long time, final int daysAgo, final File root) { if (daysAgo < 0) { return null; }//w ww . java 2 s .com Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); int days = cal.get(Calendar.DAY_OF_YEAR); if (days >= daysAgo) cal.set(Calendar.DAY_OF_YEAR, days - daysAgo); else { // TODO use getActualMaximum for days cal.set(Calendar.DAY_OF_YEAR, (354 + (days - daysAgo))); cal.set(Calendar.YEAR, cal.get(Calendar.YEAR) - 1); } // cal.getTime().toString() final Collector coll = new Collector(FileFilterUtils.andFileFilter(FileFilterUtils.directoryFileFilter(), FileFilterUtils.ageFileFilter(cal.getTime(), true)), 1); return coll.collect(root); }
From source file:com.synnex.saas.platform.core.Startup.java
@PostConstruct public void addSampleData() { Calendar cal = Calendar.getInstance(); for (int i = 0; i < 3; i++) { TransactionStatus tx = transactionManager.getTransaction(new DefaultTransactionDefinition()); String tenantId = UUID.randomUUID().toString(); Tenant tenant = new Tenant(); tenant.setHost("t" + (i + 1) + ".synnex.com:8085"); tenant.setName("Tenant-" + (i + 1)); cal.add(Calendar.DAY_OF_YEAR, 100); tenant.setRegisterDate(new Timestamp(System.currentTimeMillis())); tenant.setExpiredDate(new Timestamp(cal.getTimeInMillis())); tenant.setTenantId(tenantId);// w w w. j a v a2 s . c o m // Create sample users for (int j = 0; j < 10; j++) { // User TransactionStatus txTenant = transactionManager.getTransaction(new DefaultTransactionDefinition()); emTenant.setProperty("tenant_id", tenantId); emTenant.setProperty("eclipselink.session-name", "multi-tenant-" + tenantId); User user = new User(); user.setUserName("t" + (j + 1)); user.setNickName("Steven Li"); MessageDigestPasswordEncoder digest = new MessageDigestPasswordEncoder("md5"); user.setPassword(digest.encodePassword("password", "123")); user.setEnabled(true); cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 10); user.setRegisterDate(new Timestamp(System.currentTimeMillis())); user.setExpiredDate(new Timestamp(cal.getTimeInMillis())); emTenant.persist(user); transactionManager.commit(txTenant); } // Create sample code for (int j = 0; j < 200; j++) { // User TransactionStatus txTenant = transactionManager.getTransaction(new DefaultTransactionDefinition()); emTenant.setProperty("tenant_id", tenantId); emTenant.setProperty("eclipselink.session-name", "multi-tenant-" + tenantId); // Code Code code = new Code(); code.setName("SSSS"); emTenant.persist(code); transactionManager.commit(txTenant); } em.persist(tenant); transactionManager.commit(tx); } }
From source file:whitelabel.cloud.webapp.impl.service.LogAndJobService.java
public LogAndJob load() { LogAndJob logAndJob = new LogAndJob(); AppVirtualDatacenter vdc = loadDatacenter(); List<AppJob> jobs = null; List<AppLog> logs = null; WsEndUserClient wsClient = UserUtil.getWsEndUserClient(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, -7); List<AppLog> tmp = wsClient.getLogs(null, cal.getTime(), null); if (tmp != null) { Collections.reverse(tmp); logs = tmp;//from ww w .j a v a2 s .c o m } List<AppJob> tmp2 = wsClient.getJobs(); if (tmp2 != null) { jobs = tmp2; } if (jobs == null) { jobs = new ArrayList<AppJob>(); } if (logs == null) { logs = new ArrayList<AppLog>(); } logAndJob.setLogs(logs); logAndJob.setJobs(jobs); return logAndJob; }
From source file:org.gots.weather.provider.google.GoogleWeatherTask.java
public GoogleWeatherTask(Address address, Date requestedDay) { this.requestedDay = requestedDay; try {/*from ww w . j a v a 2 s. com*/ String weatherURL; if (GotsPreferences.isDevelopment()) weatherURL = "http://92.243.19.29/weather.xml"; else weatherURL = "http://www.google.com/ig/api?weather=" + address.getLocality() + "," + address.getCountryName(); if (today != Calendar.getInstance().get(Calendar.DAY_OF_YEAR)) force = true; if (queryString != weatherURL) force = true; today = Calendar.getInstance().get(Calendar.DAY_OF_YEAR); queryString = weatherURL; url = new URL(queryString.replace(" ", "%20")); } catch (Exception e) { Log.e("WeatherTask", e.getMessage()); } }
From source file:org.atomspace.ultrahouse3000.translator.Message2DocumentTranslator.java
void addCalenderInformation(Message message) { Calendar cal = Calendar.getInstance(); message.setHeader("timestamp", cal.getTimeInMillis()); message.setHeader("calendarYear", cal.get(Calendar.YEAR)); message.setHeader("calendarDayOfMonth", cal.get(Calendar.DAY_OF_MONTH)); message.setHeader("calendarMonth", cal.get(Calendar.MONTH)); message.setHeader("calendarDayOfYear", cal.get(Calendar.DAY_OF_YEAR)); message.setHeader("calendarHourOfDay", cal.get(Calendar.HOUR_OF_DAY)); message.setHeader("calendarMinute", cal.get(Calendar.MINUTE)); message.setHeader("calendarSecond", cal.get(Calendar.SECOND)); message.setHeader("calendarWeekOfYear", cal.get(Calendar.WEEK_OF_YEAR)); message.setHeader("calendarDayOfWeek", cal.get(Calendar.DAY_OF_WEEK)); }
From source file:Main.java
/** * <p>Checks if two calendar objects represent the same local time.</p> * * <p>This method compares the values of the fields of the two objects. * In addition, both calendars must be the same of the same type.</p> * //from w w w. jav a 2s . c o m * @param cal1 the first calendar, not altered, not null * @param cal2 the second calendar, not altered, not null * @return true if they represent the same millisecond instant * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameLocalTime(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The date must not be null"); } return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND) && cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND) && cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE) && cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.getClass() == cal2.getClass()); }
From source file:com.wso2telco.dep.mediator.publisher.RefundPublisher.java
@Override protected MessageContext modifyMessageContext(MessageContext messageContext, Long orginalPaymentTime, GroupDTO groupDTO) throws Exception { MessageContext returnMessageContext = null; if (orginalPaymentTime != null && orginalPaymentTime != 0) { final Calendar calendar = Calendar.getInstance(); int refundDayOFYear = calendar.get(Calendar.DAY_OF_YEAR); int refundYear = calendar.get(Calendar.YEAR); int refundMonth = calendar.get(Calendar.MONTH); String charegeStatus = null; LOG.debug("Current day of Year - Refund " + refundDayOFYear); LOG.debug("Current Year - Refund " + refundYear); calendar.setTimeInMillis(orginalPaymentTime); int paymentYear = calendar.get(Calendar.YEAR); int paymentDayOfYear = calendar.get(Calendar.DAY_OF_YEAR); int paymentMonth = calendar.get(Calendar.MONTH); LOG.debug("day of Year - Payment" + paymentDayOfYear); LOG.debug("Payment Year - Payment " + paymentYear); if (Double.parseDouble(groupDTO.getMonthAmount()) > 0.0) { if (refundYear == paymentYear) { if (refundMonth == paymentMonth) { returnMessageContext = messageContext; returnMessageContext.setProperty(DataPublisherConstants.PAYMENT_TYPE, MessageType.REFUND_RESPONSE.getMessageDid()); } else { LOG.info(/*from ww w .ja v a2s . co m*/ "Refund response not publish to CEP because of refund is not matching to current month"); } } else { LOG.info( "Refund response not publish to CEP because of refund is not matching to current Year"); } } } return returnMessageContext; }