List of usage examples for org.joda.time DateTime getMonthOfYear
public int getMonthOfYear()
From source file:com.inkubator.hrm.service.impl.WtHolidayCronListenerServiceImpl.java
public void updateWtHolidayDateWhereIsEveryYearIsOne() throws Exception { LOGGER.warn("Begin Running Update WtHoliday"); //ambil bulan dan taun januari sekarang DateTime monthAndYearNow = new DateTime(); List<WtHoliday> dataToUpdate = wtHolidayDao.getByYearDif(difWeekToDelete); LOGGER.info("Ukuran Data to Update " + dataToUpdate.size()); Date date = new Date(); WtHoliday newData;//from www .j a v a 2s . c o m Long totalDuplicat; for (WtHoliday wtHoliday : dataToUpdate) { //ambil bulan dan tahun yang akan di update DateTime monthAndYearBefore = new DateTime(wtHoliday.getHolidayDate()); //jika tahun di database lebih kecil tahun sekarang if (monthAndYearBefore.getYear() < monthAndYearNow.getYear() && monthAndYearBefore.getMonthOfYear() >= monthAndYearNow.getMonthOfYear()) { // //cari nama + tahun, jika sudah ada skip, karena unik totalDuplicat = wtHolidayDao.getTotalWtHolidayByHolidayName( wtHoliday.getHolidayName() + " " + monthAndYearNow.getYear()); if (totalDuplicat == 0) { Date updateHolidayDate = DateTimeUtil.getDateFrom(wtHoliday.getHolidayDate(), 1, CommonUtilConstant.DATE_FORMAT_YEAR); newData = new WtHoliday(); newData.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(9))); newData.setHolidayName(wtHoliday.getHolidayName() + " " + monthAndYearNow.getYear()); newData.setIsColectiveLeave(wtHoliday.getIsColectiveLeave()); newData.setIsEveryYear(wtHoliday.getIsEveryYear()); if (wtHoliday.getReligion() != null) { newData.setReligion(wtHoliday.getReligion()); } newData.setCreatedBy(HRMConstant.INKUBA_SYSTEM); newData.setCreatedOn(new Date()); newData.setHolidayDate(updateHolidayDate); wtHolidayDao.save(newData); } } } LOGGER.info("Finish Running Update Wt Holiday"); }
From source file:com.inkubator.hrm.util.KodefikasiUtil.java
public static String getKodefikasi(int maxNumerData, String pattern) { String afterString = StringUtils.substringAfter(pattern, "["); String beforeString = StringUtils.substringBefore(pattern, "["); String removeParenties1 = StringUtils.remove(afterString, "["); String removeParenties2 = StringUtils.remove(removeParenties1, "]"); int numberOfYear = StringUtils.countMatches(removeParenties2, "Y"); int numberofN = StringUtils.countMatches(removeParenties2, "N"); int currentNumber = maxNumerData + 1; int numberofNEx = String.valueOf(currentNumber).length(); int selisih = numberofN - numberofNEx; String montInString = null;/* www. j a v a 2 s. com*/ String yearInString = null; String dayInString = null; String numberInString = null; if (selisih == 0) { numberInString = String.valueOf(currentNumber); } else { numberInString = StringUtils.leftPad(String.valueOf(currentNumber), numberofN, "0"); } DateTime jodaTime = new DateTime(); int year = jodaTime.getYear(); int month = jodaTime.getMonthOfYear(); int day = jodaTime.getDayOfMonth(); if (month < 10) { montInString = "0" + month; } else { montInString = String.valueOf(month); } if (numberOfYear == 2) { year = Integer.parseInt(new SimpleDateFormat("YY").format(new Date())); if (year < 10) { yearInString = "0" + year; } else { yearInString = String.valueOf(year); } } else { yearInString = String.valueOf(year); } if (day < 10) { dayInString = "0" + day; } else { dayInString = String.valueOf(day); } String output1 = StringUtils.replaceOnce(removeParenties2, "Y", yearInString); String output2 = StringUtils.remove(output1, "Y"); String output3 = StringUtils.replaceOnce(output2, "M", montInString); String output4 = StringUtils.remove(output3, "M"); String output5 = StringUtils.replaceOnce(output4, "D", dayInString); String output6 = StringUtils.remove(output5, "D"); String output7 = StringUtils.replaceOnce(output6, "N", numberInString); String output8 = StringUtils.remove(output7, "N"); return beforeString + output8; }
From source file:com.inkubator.hrm.util.KodefikasiUtil.java
public static String getKodefikasiOnlyPattern(String pattern) { String afterString = StringUtils.substringAfter(pattern, "["); String beforeString = StringUtils.substringBefore(pattern, "["); String removeParenties1 = StringUtils.remove(afterString, "["); String removeParenties2 = StringUtils.remove(removeParenties1, "]"); int numberOfYear = StringUtils.countMatches(removeParenties2, "Y"); int numberofN = StringUtils.countMatches(removeParenties2, "N"); // int currentNumber = maxNumerData + 1; // int numberofNEx = String.valueOf(currentNumber).length(); // int selisih = numberofN - numberofNEx; String montInString = null;/* w w w . j av a 2 s . c o m*/ String yearInString = null; String dayInString = null; String numberInString = null; // if (selisih == 0) { // numberInString = String.valueOf(currentNumber); // } else { //// numberInString = StringsUtils.leftPad(String.valueOf(currentNumber), numberofN, "0"); // } DateTime jodaTime = new DateTime(); int year = jodaTime.getYear(); int month = jodaTime.getMonthOfYear(); int day = jodaTime.getDayOfMonth(); if (month < 10) { montInString = "0" + month; } else { montInString = String.valueOf(month); } if (numberOfYear == 2) { year = Integer.parseInt(new SimpleDateFormat("YY").format(new Date())); if (year < 10) { yearInString = "0" + year; } else { yearInString = String.valueOf(year); } } else { yearInString = String.valueOf(year); } if (day < 10) { dayInString = "0" + day; } else { dayInString = String.valueOf(day); } String output1 = StringUtils.replaceOnce(removeParenties2, "Y", yearInString); String output2 = StringUtils.remove(output1, "Y"); String output3 = StringUtils.replaceOnce(output2, "M", montInString); String output4 = StringUtils.remove(output3, "M"); String output5 = StringUtils.replaceOnce(output4, "D", dayInString); String output6 = StringUtils.remove(output5, "D"); // String output7 = StringsUtils.replaceOnce(output6, "N", numberInString); // String output8 = StringsUtils.remove(output7, "N"); return beforeString + output6; }
From source file:com.inspireVeiN.iPlayed.iPlayedPlayerListener.java
License:Open Source License
private void login(Player p) { String player = p.getName();/*from w w w . j a v a 2 s.c om*/ Arguments entry = null; if (plugin.timesdb.hasIndex(player)) entry = plugin.timesdb.getArguments(player); else { entry = new Arguments(player); entry.setValue("playtime", "0"); plugin.timesdb.addIndex(player, entry); plugin.timesdb.update(); } DateTime dt = new DateTime(); plugin.timesdb.setArgument(player, "lastlogin", dt.getMonthOfYear() + "/" + dt.getDayOfMonth() + "/" + dt.getYear(), true); plugin.timesdb.setArgument(player, "startTime", Integer.toString(dt.getMinuteOfDay()), true); }
From source file:com.krminc.phr.web.PHRCalendar.java
License:Apache License
public PHRCalendar(Long healthRecordId) { this.healthRecordId = healthRecordId; this.healthRecord = lookupHealthRecord(this.healthRecordId); // TODO: Is there a way we can do this without creating an object? DateTime now = new DateTime(); this.year = now.getYear(); this.month = now.getMonthOfYear(); }
From source file:com.linkedin.cubert.utils.FileSystemUtils.java
License:Open Source License
public static List<Path> getDurationPaths(FileSystem fs, Path root, DateTime startDate, DateTime endDate, boolean isDaily, int hourStep, boolean errorOnMissing, boolean useHourlyForMissingDaily) throws IOException { List<Path> paths = new ArrayList<Path>(); while (endDate.compareTo(startDate) >= 0) { Path loc;/*w ww.j a v a 2 s . c om*/ if (isDaily) loc = generateDatedPath(root, endDate.getYear(), endDate.getMonthOfYear(), endDate.getDayOfMonth()); else loc = generateDatedPath(root, endDate.getYear(), endDate.getMonthOfYear(), endDate.getDayOfMonth(), endDate.getHourOfDay()); // Check that directory exists, and contains avro files. if (fs.exists(loc) && fs.globStatus(new Path(loc, "*" + "avro")).length > 0) { paths.add(loc); } else { loc = generateDatedPath(new Path(root.getParent(), "hourly"), endDate.getYear(), endDate.getMonthOfYear(), endDate.getDayOfMonth()); if (isDaily && useHourlyForMissingDaily && fs.exists(loc)) { for (FileStatus hour : fs.listStatus(loc)) { paths.add(hour.getPath()); } } else if (errorOnMissing) { throw new RuntimeException("Missing directory " + loc.toString()); } } if (hourStep == 24) endDate = endDate.minusDays(1); else endDate = endDate.minusHours(hourStep); } return paths; }
From source file:com.manydesigns.portofino.calendar.AbstractMonthView.java
License:Open Source License
public AbstractMonthView(DateTime referenceDateTime, int firstDayOfWeek) { logger.debug("Initializing month"); this.referenceDateTime = referenceDateTime; logger.debug("Reference date time: {}", referenceDateTime); this.firstDayOfWeek = firstDayOfWeek; logger.debug("First day of week: {}", firstDayOfWeek); referenceDateMidnight = new DateMidnight(referenceDateTime); referenceYear = referenceDateTime.getYear(); referenceMonth = referenceDateTime.getMonthOfYear(); monthStart = referenceDateMidnight.withDayOfMonth(1); monthEnd = monthStart.plusMonths(1); monthInterval = new Interval(monthStart, monthEnd); monthViewStart = monthStart.withDayOfWeek(firstDayOfWeek); monthViewEnd = monthViewStart.plusWeeks(6); monthViewInterval = new Interval(monthViewStart, monthViewEnd); logger.debug("Month view start: {}", monthViewStart); logger.debug("Initializing weeks"); weeks = createWeeksArray(6);/*from w ww . j a va 2 s .c om*/ DateMidnight weekStart = monthViewStart; for (int i = 0; i < weeks.length; i++) { DateMidnight weekEnd = weekStart.plusWeeks(1); weeks[i] = createWeek(weekStart, weekEnd); weekStart = weekEnd; } }
From source file:com.marand.thinkmed.medications.business.impl.DefaultMedicationsBo.java
License:Open Source License
@Override public List<TherapySurgeryReportElementDto> getTherapySurgeryReportElements(@Nonnull final String patientId, final Double patientHeight, @Nonnull final DateTime searchStart, @Nonnull final RoundsIntervalDto roundsIntervalDto, @Nonnull final Locale locale, @Nonnull final DateTime when) { Preconditions.checkNotNull(patientId, "patientId"); Preconditions.checkNotNull(searchStart, "searchStart"); Preconditions.checkNotNull(roundsIntervalDto, "roundsIntervalDto"); Preconditions.checkNotNull(locale, "locale"); Preconditions.checkNotNull(when, "when"); final DateTime roundsStart = new DateTime(searchStart.getYear(), searchStart.getMonthOfYear(), searchStart.getDayOfMonth(), roundsIntervalDto.getStartHour(), roundsIntervalDto.getStartMinute()); final List<Pair<MedicationOrderComposition, MedicationInstructionInstruction>> instructionsList = medicationsOpenEhrDao .findMedicationInstructions(patientId, Intervals.infiniteFrom(roundsStart), null); final Double referenceWeight = medicationsOpenEhrDao.getPatientLastReferenceWeight(patientId, Intervals.infiniteTo(searchStart)); final List<TherapySurgeryReportElementDto> elements = new ArrayList<>(); final Map<Long, MedicationDataForTherapyDto> medicationsMap = getMedicationDataForTherapies( instructionsList, null);/*from w ww .j a v a2 s .co m*/ for (final Pair<MedicationOrderComposition, MedicationInstructionInstruction> instructionPair : instructionsList) { final MedicationOrderComposition composition = instructionPair.getFirst(); final MedicationInstructionInstruction instruction = instructionPair.getSecond(); final MedicationTimingCluster medicationTiming = instruction.getOrder().get(0).getMedicationTiming(); final Interval instructionInterval = MedicationsEhrUtils.getInstructionInterval(medicationTiming); final boolean onlyOnce = isOnlyOnceThenEx(medicationTiming); if (instructionInterval.overlaps(Intervals.infiniteFrom(searchStart)) || onlyOnce && instructionInterval.getStart().isAfter(searchStart.minusHours(1))) { final List<MedicationActionAction> actions = MedicationsEhrUtils.getInstructionActions(composition, instruction); if (!isTherapyCanceledAbortedOrSuspended(actions)) { final TherapyDto therapy = getTherapyFromMedicationInstruction(composition, instruction, referenceWeight, patientHeight, when); therapyDisplayProvider.fillDisplayValues(therapy, false, true, false, locale, true); final boolean containsAntibiotics = getMedicationIds( MedicationsEhrUtils.getRepresentingOrderActivity(instruction)).stream().anyMatch( id -> medicationsMap.containsKey(id) && medicationsMap.get(id).isAntibiotic()); if (containsAntibiotics) { final int consecutiveDays = getTherapyConsecutiveDay( getOriginalTherapyStart(patientId, composition), when, when, therapy.getPastDaysOfTherapy()); elements.add(new TherapySurgeryReportElementDto(therapy.getFormattedTherapyDisplay(), consecutiveDays)); } else { elements.add(new TherapySurgeryReportElementDto(therapy.getFormattedTherapyDisplay())); } } } } return elements; }
From source file:com.marand.thinkmed.medications.dto.report.TherapyDayReportUtils.java
License:Open Source License
private static String combineTimeAndQuantity(final DateTime date, final String time, final String quantity) { final StringBuilder sb = new StringBuilder(); if (date != null) { sb.append("<br>" + date.getDayOfMonth() + "." + date.getMonthOfYear()); }/* w ww.ja v a 2s .c om*/ sb.append("<br> " + time + " - " + quantity); return sb.toString(); }
From source file:com.marand.thinkmed.medications.process.impl.TherapyTaskCreatorImpl.java
License:Open Source License
private List<NewTaskRequestDto> createTasks(final Long patientId, final MedicationOrderComposition composition, final MedicationInstructionInstruction instruction, final AdministrationTimingDto administrationTiming, final RoundsIntervalDto roundsInterval, final List<Interval> tasksCreationIntervals, final boolean therapyStart, final DateTime lastTaskTimestamp) { final boolean simple = MedicationsEhrUtils.isSimpleInstruction(instruction); final boolean variable = MedicationsEhrUtils.isVariableInstruction(instruction); final boolean variableDays = MedicationsEhrUtils.isVariableDaysInstruction(instruction); String linkedTherapyId = null; //last task triggers task creation for linked therapy final Pair<MedicationOrderComposition, MedicationInstructionInstruction> instructionPair = Pair .of(composition, instruction); for (final MedicationInstructionInstruction inst : composition.getMedicationDetail() .getMedicationInstruction()) { if (medicationsBo.doesInstructionHaveLinkToCompareInstruction(inst, instructionPair, OpenEhrLinkType.ISSUE)) { linkedTherapyId = InstructionTranslator.translate(inst, composition); break; }//from w ww . j a v a 2s.com } final List<NewTaskRequestDto> taskRequests = new ArrayList<>(); for (final Interval interval : tasksCreationIntervals) { if (variableDays) { final Map<DateTime, TherapyDoseDto> administrationDateTimesMap = new HashMap<>(); for (final OrderActivity orderActivity : instruction.getOrder()) { final TherapyDoseDto dose = getTherapyDoseDto(orderActivity, simple); if (dose != null) { final DvTime dvTime = orderActivity.getMedicationTiming().getTiming().getTime().get(0); final DvDate dvDate = orderActivity.getMedicationTiming().getTiming().getDate().get(0); final Pair<Integer, Integer> parsedTime = DvUtils.getHourMinute(dvTime); final DateTime parsedDate = ISODateTimeFormat.date().parseDateTime(dvDate.getValue()); administrationDateTimesMap.put( new DateTime(parsedDate.getYear(), parsedDate.getMonthOfYear(), parsedDate.getDayOfMonth(), parsedTime.getFirst(), parsedTime.getSecond()), dose); } } final List<NewTaskRequestDto> tasks = createTasksForVariableDaysTherapy(patientId, instruction, composition.getUid().getValue(), interval, administrationDateTimesMap, therapyStart); taskRequests.addAll(tasks); } else if (variable) { final Map<HourMinuteDto, TherapyDoseDto> administrationTimesMap = new HashMap<>(); for (final OrderActivity orderActivity : instruction.getOrder()) { final TherapyDoseDto dose = getTherapyDoseDto(orderActivity, simple); final Pair<Integer, Integer> parsedTime = DvUtils .getHourMinute(orderActivity.getMedicationTiming().getTiming().getTime().get(0)); administrationTimesMap.put(new HourMinuteDto(parsedTime.getFirst(), parsedTime.getSecond()), dose); } final List<NewTaskRequestDto> tasks = createTasksForVariableTherapy(patientId, instruction, composition.getUid().getValue(), interval, administrationTimesMap, therapyStart); taskRequests.addAll(tasks); } else { final TherapyDoseDto dose = getTherapyDoseDto(instruction.getOrder().get(0), simple); final List<NewTaskRequestDto> tasks = createTasksForConstantTherapy(patientId, instruction, composition.getUid().getValue(), interval, dose, administrationTiming, roundsInterval, therapyStart, lastTaskTimestamp, linkedTherapyId); taskRequests.addAll(tasks); } } return taskRequests; }