@Test public void getWeekNoByDateTest() { LocalDate date = LocalDate.now(); projectionRepositoryImpl.getWeekNoByDate(date); }
public int getWeekNoByDate(LocalDate date) { LocalDate lastDayInPreviousQuarter = null; int quarter = date.get(IsoFields.QUARTER_OF_YEAR); int weekNumber; if (quarter > 1) { LocalDate previousQuarter = LocalDate.now().minus(1, IsoFields.QUARTER_YEARS); long lastDayOfQuarter = IsoFields.DAY_OF_QUARTER.rangeRefinedBy(previousQuarter).getMaximum(); lastDayInPreviousQuarter = previousQuarter.with(IsoFields.DAY_OF_QUARTER, lastDayOfQuarter); } WeekFields weekFields = WeekFields.of(Locale.getDefault()); if (null != lastDayInPreviousQuarter) { weekNumber = ((date.get(weekFields.weekOfWeekBasedYear())) - (lastDayInPreviousQuarter.get(weekFields .weekOfWeekBasedYear()))); } else { weekNumber = date.get(weekFields.weekOfWeekBasedYear()); } return weekNumber; }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public int getWeekNoByDate(LocalDate date) { LocalDate lastDayInPreviousQuarter = null; int quarter = date.get(IsoFields.QUARTER_OF_YEAR); int weekNumber; if (quarter > 1) { LocalDate previousQuarter = LocalDate.now().minus(1, IsoFields.QUARTER_YEARS); long lastDayOfQuarter = IsoFields.DAY_OF_QUARTER.rangeRefinedBy(previousQuarter).getMaximum(); lastDayInPreviousQuarter = previousQuarter.with(IsoFields.DAY_OF_QUARTER, lastDayOfQuarter); } WeekFields weekFields = WeekFields.of(Locale.getDefault()); if (null != lastDayInPreviousQuarter) { weekNumber = ((date.get(weekFields.weekOfWeekBasedYear())) - (lastDayInPreviousQuarter.get(weekFields .weekOfWeekBasedYear()))); } else { weekNumber = date.get(weekFields.weekOfWeekBasedYear()); } return weekNumber; } }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public int getWeekNoByDate(LocalDate date) { LocalDate lastDayInPreviousQuarter = null; int quarter = date.get(IsoFields.QUARTER_OF_YEAR); int weekNumber; if (quarter > 1) { LocalDate previousQuarter = LocalDate.now().minus(1, IsoFields.QUARTER_YEARS); long lastDayOfQuarter = IsoFields.DAY_OF_QUARTER.rangeRefinedBy(previousQuarter).getMaximum(); lastDayInPreviousQuarter = previousQuarter.with(IsoFields.DAY_OF_QUARTER, lastDayOfQuarter); } WeekFields weekFields = WeekFields.of(Locale.getDefault()); if (null != lastDayInPreviousQuarter) { weekNumber = ((date.get(weekFields.weekOfWeekBasedYear())) - (lastDayInPreviousQuarter.get(weekFields .weekOfWeekBasedYear()))); } else { weekNumber = date.get(weekFields.weekOfWeekBasedYear()); } return weekNumber; }  }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public int getWeekNoByDate(LocalDate date) { LocalDate lastDayInPreviousQuarter = null; int quarter = date.get(IsoFields.QUARTER_OF_YEAR); int weekNumber; if (quarter > 1) { LocalDate previousQuarter = LocalDate.now().minus(1, IsoFields.QUARTER_YEARS); long lastDayOfQuarter = IsoFields.DAY_OF_QUARTER.rangeRefinedBy(previousQuarter).getMaximum(); lastDayInPreviousQuarter = previousQuarter.with(IsoFields.DAY_OF_QUARTER, lastDayOfQuarter); } WeekFields weekFields = WeekFields.of(Locale.getDefault()); if (null != lastDayInPreviousQuarter) { weekNumber = ((date.get(weekFields.weekOfWeekBasedYear())) - (lastDayInPreviousQuarter.get(weekFields .weekOfWeekBasedYear()))); } else { weekNumber = date.get(weekFields.weekOfWeekBasedYear()); } return weekNumber; }  @Override Boolean updateProjectionByTargetType(ProjectionRequest projectionRequest); @Override List<Map<String, Object>> getProjectionDetailsFromDb(String targetType, int year, int quarter); @Override Long getTotalAssetCountByTargetType(String targetType); List<LocalDate> getListOfLastWeekDateOfQuarter(); int getWeekNoByDate(LocalDate date); @Override Map<Integer, Long> getPatchingSnapshot(String assetGroup); Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType); Map<String, Long> getAssetDetailsByApplication(String assetGroup, String resourceType); Long getAssetCountByAg(String assetGroup, String resourceType); @SuppressWarnings("deprecation") List<Map<String, Object>> getAppsDetails(String appType); }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public int getWeekNoByDate(LocalDate date) { LocalDate lastDayInPreviousQuarter = null; int quarter = date.get(IsoFields.QUARTER_OF_YEAR); int weekNumber; if (quarter > 1) { LocalDate previousQuarter = LocalDate.now().minus(1, IsoFields.QUARTER_YEARS); long lastDayOfQuarter = IsoFields.DAY_OF_QUARTER.rangeRefinedBy(previousQuarter).getMaximum(); lastDayInPreviousQuarter = previousQuarter.with(IsoFields.DAY_OF_QUARTER, lastDayOfQuarter); } WeekFields weekFields = WeekFields.of(Locale.getDefault()); if (null != lastDayInPreviousQuarter) { weekNumber = ((date.get(weekFields.weekOfWeekBasedYear())) - (lastDayInPreviousQuarter.get(weekFields .weekOfWeekBasedYear()))); } else { weekNumber = date.get(weekFields.weekOfWeekBasedYear()); } return weekNumber; }  @Override Boolean updateProjectionByTargetType(ProjectionRequest projectionRequest); @Override List<Map<String, Object>> getProjectionDetailsFromDb(String targetType, int year, int quarter); @Override Long getTotalAssetCountByTargetType(String targetType); List<LocalDate> getListOfLastWeekDateOfQuarter(); int getWeekNoByDate(LocalDate date); @Override Map<Integer, Long> getPatchingSnapshot(String assetGroup); Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType); Map<String, Long> getAssetDetailsByApplication(String assetGroup, String resourceType); Long getAssetCountByAg(String assetGroup, String resourceType); @SuppressWarnings("deprecation") List<Map<String, Object>> getAppsDetails(String appType);  }