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.greenline.guahao.biz.util.DateUtils.java
/** * ???0?7?/*from w w w . j ava 2 s. com*/ * * @param date * @return int */ public static int getIndexInCycle(String date) { try { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 1); // int d = cal.get(Calendar.DAY_OF_WEEK); // cal.setTime(df.parse(date)); int id = cal.get(Calendar.DAY_OF_WEEK); // int idx = id - d; idx = idx < 0 ? idx + 7 : idx; // 7 return idx; } catch (Exception e) { logger.error("???", e); } return -1; }
From source file:fitnesse.components.Logger.java
private boolean needNewFile(Calendar time) { if (writer == null) return true; else {/*w ww .jav a 2 s . c o m*/ boolean different = (time.get(Calendar.DAY_OF_YEAR) != currentFileCreationDate .get(Calendar.DAY_OF_YEAR)) || (time.get(Calendar.YEAR) != currentFileCreationDate.get(Calendar.YEAR)); return different; } }
From source file:org.bwgz.swim.openlane.service.EventServiceImpl.java
private long calculateAge(Date meetAgeDate, Date dateOfBirth) { Calendar mad = Calendar.getInstance(); Calendar dob = Calendar.getInstance(); mad.setTime(meetAgeDate);/*from w ww . j a v a 2 s . c o m*/ dob.setTime(dateOfBirth); if (dob.after(mad)) { throw new IllegalArgumentException("Can't be born in the future"); } int age = mad.get(Calendar.YEAR) - dob.get(Calendar.YEAR); if (mad.get(Calendar.DAY_OF_YEAR) < dob.get(Calendar.DAY_OF_YEAR)) { age--; } return age; }
From source file:whitelabel.cloud.webapp.impl.service.DashboardService.java
public Dashboard load() { Dashboard dashboard = new Dashboard(); WsEndUserClient wsClient = UserUtil.getWsEndUserClient(); AppCredit credit = wsClient.getAvailableCredit(); dashboard.setCredit(credit);//from ww w . j ava2s .com AppVirtualDatacenter vdc = loadDatacenter(); List<AppServerDetails> servers = null; List<AppLog> logs = null; if (vdc != null) { servers = vdc.getServers(); } 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; } if (servers == null) { servers = new ArrayList<AppServerDetails>(); } if (logs == null) { logs = new ArrayList<AppLog>(); } dashboard.setLogs(logs); dashboard.setServers(servers); return dashboard; }
From source file:sk.lazyman.gizmo.util.GizmoUtils.java
public static Date addOneDay(Date date) { if (date == null) { return null; }// www . j av a2 s . c o m Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DAY_OF_YEAR, 1); return cal.getTime(); }
From source file:com.redhat.rhn.manager.monitoring.ModifyFilterCommand.java
/** * Create a command that modifies a new filter. * @param user0 the user modifying the filter */// w ww . j a va 2 s.co m public ModifyFilterCommand(User user0) { user = user0; filter = new Filter(); filter.setUser(user); filter.setOrg(user.getOrg()); filter.setType(NotificationFactory.FILTER_TYPE_REDIR); filter.setRecurringBool(Boolean.FALSE); now = new Date(); Calendar sevenDays = Calendar.getInstance(); sevenDays.add(Calendar.DAY_OF_YEAR, 7); filter.setExpiration(sevenDays.getTime()); filter.setStartDate(now); }
From source file:com.adaptris.core.fs.OlderThanTest.java
private long yesterday() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, -1); return cal.getTime().getTime(); }
From source file:de.knurt.fam.core.util.time.CalendarUtil.java
/** * return the number of days between the given to calendar instances. the * result is always a positive long value. * //w ww . j a va 2 s .co m * @param c1 * first calendar instance * @param c2 * second calendar instance * @return the number of days between the given to calendar instances */ public long daysBetween(Calendar c1, Calendar c2) { long result = 0l; while (!DateUtils.isSameDay(c1, c2)) { result++; if (c1.before(c2)) { c1.add(Calendar.DAY_OF_YEAR, 1); } else { c2.add(Calendar.DAY_OF_YEAR, 1); } } return result; }
From source file:com.lk.ofo.util.DateUtil.java
/** * /*from ww w . j ava2 s . co m*/ * * @param date * @param changeValue ? * @return */ public static Date changeDay(Date date, int changeValue) { if (date == null || changeValue == 0) { return date; } Calendar c = Calendar.getInstance(); c.setTime(date); c.add(Calendar.DAY_OF_YEAR, changeValue); return c.getTime(); }