List of usage examples for java.util Calendar WEEK_OF_YEAR
int WEEK_OF_YEAR
To view the source code for java.util Calendar WEEK_OF_YEAR.
Click Source Link
get
and set
indicating the week number within the current year. From source file:verdandi.model.WeekSelectorModel.java
private String getDateValue(int diff) { Calendar other = (Calendar) cal.clone(); StringBuffer buf = new StringBuffer(); buf.append(WEEK_OF_YEAR_PREFIX);//from w w w. j a v a 2 s. co m if (diff != 0) { other.add(Calendar.WEEK_OF_YEAR, diff); LOG.debug("Current date: " + cal.getTime() + ", New Date: " + other.getTime() + ", diff: " + diff); } if (other.get(Calendar.WEEK_OF_YEAR) < 10) { buf.append("0"); } buf.append(other.get(Calendar.WEEK_OF_YEAR)); buf.append(": "); other.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); buf.append(dfmt.format(other.getTime())); buf.append(" - "); other.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); buf.append(dfmt.format(other.getTime())); return buf.toString(); }
From source file:org.sonar.db.purge.period.Filters.java
Filters(Settings settings) { Date dateToStartKeepingOneSnapshotByDay = getDateFromHours(settings, PurgeConstants.HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY); Date dateToStartKeepingOneSnapshotByWeek = getDateFromWeeks(settings, PurgeConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK); Date dateToStartKeepingOneSnapshotByMonth = getDateFromWeeks(settings, PurgeConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH); Date dateToStartDeletingAllSnapshots = getDateFromWeeks(settings, PurgeConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS); all.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByWeek, dateToStartKeepingOneSnapshotByDay, Calendar.DAY_OF_YEAR, "day")); all.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByMonth, dateToStartKeepingOneSnapshotByWeek, Calendar.WEEK_OF_YEAR, "week")); all.add(new KeepOneFilter(dateToStartDeletingAllSnapshots, dateToStartKeepingOneSnapshotByMonth, Calendar.MONTH, "month")); all.add(new DeleteAllFilter(dateToStartDeletingAllSnapshots)); }
From source file:org.sonar.plugins.dbcleaner.period.Filters.java
Filters(Settings settings) { Date dateToStartKeepingOneSnapshotByDay = getDateFromHours(settings, DbCleanerConstants.HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY); Date dateToStartKeepingOneSnapshotByWeek = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK); Date dateToStartKeepingOneSnapshotByMonth = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH); Date dateToStartDeletingAllSnapshots = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS); filters.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByWeek, dateToStartKeepingOneSnapshotByDay, Calendar.DAY_OF_YEAR, "day")); filters.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByMonth, dateToStartKeepingOneSnapshotByWeek, Calendar.WEEK_OF_YEAR, "week")); filters.add(new KeepOneFilter(dateToStartDeletingAllSnapshots, dateToStartKeepingOneSnapshotByMonth, Calendar.MONTH, "month")); filters.add(new DeleteAllFilter(dateToStartDeletingAllSnapshots)); }
From source file:org.sonar.core.computation.dbcleaner.period.Filters.java
Filters(Settings settings) { Date dateToStartKeepingOneSnapshotByDay = getDateFromHours(settings, DbCleanerConstants.HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY); Date dateToStartKeepingOneSnapshotByWeek = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK); Date dateToStartKeepingOneSnapshotByMonth = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH); Date dateToStartDeletingAllSnapshots = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS); all.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByWeek, dateToStartKeepingOneSnapshotByDay, Calendar.DAY_OF_YEAR, "day")); all.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByMonth, dateToStartKeepingOneSnapshotByWeek, Calendar.WEEK_OF_YEAR, "week")); all.add(new KeepOneFilter(dateToStartDeletingAllSnapshots, dateToStartKeepingOneSnapshotByMonth, Calendar.MONTH, "month")); all.add(new DeleteAllFilter(dateToStartDeletingAllSnapshots)); }
From source file:org.apache.hadoop.hive.ql.udf.UDFWeekOfYear.java
public IntWritable evaluate(Text dateString) { if (dateString == null) { return null; }/*w w w.j a v a 2s . c o m*/ try { Date date = formatter.parse(dateString.toString()); calendar.setTime(date); result.set(calendar.get(Calendar.WEEK_OF_YEAR)); return result; } catch (ParseException e) { return null; } }
From source file:verdandi.model.CurrentWeekModel.java
/** * @param week/* w ww.j a va 2 s . co m*/ */ @Deprecated public void setCurrentWeek(int week) { LOG.debug("Setting current week to " + week); if (week > 52) { week = week % 52; LOG.debug("week > 52 rewritten to " + week); } cal.set(Calendar.WEEK_OF_YEAR, week); fireCurrentWeekChanged(); }
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:org.openmrs.module.clinicalsummary.rule.reminder.peds.pneumocystis.PolymeraseBasedReminderRule.java
/** * @see org.openmrs.logic.Rule#eval(org.openmrs.logic.LogicContext, Integer, java.util.Map) */// w ww . j av a 2s . co m @Override protected Result evaluate(final LogicContext context, final Integer patientId, final Map<String, Object> parameters) throws LogicException { Result result = new Result(); Patient patient = Context.getPatientService().getPatient(patientId); if (patient.getBirthdate() != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(patient.getBirthdate()); calendar.add(Calendar.WEEK_OF_YEAR, 6); Date sixWeeks = calendar.getTime(); calendar.setTime(patient.getBirthdate()); calendar.add(Calendar.MONTH, 18); Date eighteenMonths = calendar.getTime(); if (sixWeeks.before(new Date()) && eighteenMonths.after(new Date())) { ValidPolymeraseRule validPolymeraseRule = new ValidPolymeraseRule(); parameters.put(EvaluableConstants.OBS_FETCH_SIZE, 2); parameters.put(EvaluableConstants.OBS_CONCEPT, Arrays.asList(EvaluableNameConstants.HIV_DNA_POLYMERASE_CHAIN_REACTION_QUALITATIVE)); parameters.put(EvaluableConstants.OBS_VALUE_CODED, Arrays.asList(EvaluableNameConstants.NEGATIVE)); Result validPolymeraseResults = validPolymeraseRule.eval(context, patientId, parameters); // if we have less than 2 negative results if (CollectionUtils.isNotEmpty(validPolymeraseResults) && CollectionUtils.size(validPolymeraseResults) < 2) { parameters.remove(EvaluableConstants.OBS_CONCEPT); parameters.remove(EvaluableConstants.OBS_VALUE_CODED); parameters.remove(EvaluableConstants.OBS_FETCH_ORDER); parameters.remove(EvaluableConstants.OBS_FETCH_SIZE); PneumocystisCariniiRule pneumocystisCariniiRule = new PneumocystisCariniiRule(); parameters.put(EvaluableConstants.ENCOUNTER_TYPE, Arrays.asList(EvaluableNameConstants.ENCOUNTER_TYPE_PEDIATRIC_INITIAL, EvaluableNameConstants.ENCOUNTER_TYPE_PEDIATRIC_RETURN, EvaluableNameConstants.ENCOUNTER_TYPE_PEDIATRIC_NONCLINICALMEDICATION)); Result pneumocystisCariniiResults = pneumocystisCariniiRule.eval(context, patientId, parameters); if (CollectionUtils.isEmpty(pneumocystisCariniiResults)) result.add(new Result( String.valueOf(parameters.get(ReminderParameters.DISPLAYED_REMINDER_TEXT)))); } } } return result; }
From source file:org.openmrs.module.clinicalsummary.rule.reminder.peds.fragment.ValidPolymeraseRule.java
/** * @see org.openmrs.logic.Rule#eval(org.openmrs.logic.LogicContext, Integer, java.util.Map) *///from www . j a v a2s. co m @Override protected Result evaluate(final LogicContext context, final Integer patientId, final Map<String, Object> parameters) throws LogicException { Result result = new Result(); Patient patient = Context.getPatientService().getPatient(patientId); if (patient.getBirthdate() != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(patient.getBirthdate()); calendar.add(Calendar.WEEK_OF_YEAR, 4); Date validReferenceDate = calendar.getTime(); // user of the rule can override this value if they want to if (!parameters.containsKey(EvaluableConstants.OBS_CONCEPT)) parameters.put(EvaluableConstants.OBS_CONCEPT, Arrays.asList(EvaluableNameConstants.HIV_DNA_POLYMERASE_CHAIN_REACTION_QUALITATIVE)); ObsWithRestrictionRule obsWithRestrictionRule = new ObsWithStringRestrictionRule(); Result validPolymeraseResults = obsWithRestrictionRule.eval(context, patientId, parameters); for (Result validPolymeraseResult : validPolymeraseResults) { if (validPolymeraseResult.getResultDate().after(validReferenceDate)) result.add(validPolymeraseResult); } } return result; }
From source file:org.apache.hadoop.hive.ql.udf.UDFWeekOfYear.java
public IntWritable evaluate(TimestampWritable t) { if (t == null) { return null; }/*w ww . j ava 2 s . co m*/ calendar.setTime(t.getTimestamp()); result.set(calendar.get(Calendar.WEEK_OF_YEAR)); return result; }