List of usage examples for org.joda.time DateTime getYearOfEra
public int getYearOfEra()
From source file:com.barchart.feed.ddf.util.HelperDDF.java
License:BSD License
/** * from millisUTC into ddf "20100616124807". * // w ww. java2 s. c o m * @param millisUTC * the millis utc * @param zone * the zone * @return the long */ public static final long timeEncode(final long millisUTC, final DateTimeZone zone) { final DateTime dateTime = new DateTime(millisUTC, zone); long value = 0; final int year = dateTime.getYearOfEra(); value += year; value *= 100; final int month = dateTime.getMonthOfYear(); value += month; value *= 100; final int day = dateTime.getDayOfMonth(); value += day; value *= 100; final int hour = dateTime.getHourOfDay(); value += hour; value *= 100; final int minute = dateTime.getMinuteOfHour(); value += minute; value *= 100; final int second = dateTime.getSecondOfMinute(); value += second; return value; }
From source file:com.huang.rp.blog.access.service.AccessService.java
License:Apache License
/** * ?// ww w. j a v a2 s. com * @return */ public Map<String, Map<String, List<BlogPostsWithBLOBs>>> getTimelineList(HttpServletRequest request, AccessFilter filter) { if (filter == null) filter = new AccessFilter(); filter.setRows(Integer.MAX_VALUE - 1); filter.setSord("desc"); filter.setSidx("id"); CookieVO cookieVO = parseCookie(request); filter.setSearchStr(cookieVO.getSearch()); filter.setTagId(cookieVO.getTag()); filter.setUserId(cookieVO.getUserId()); filter.setHighLight(true); List<BlogPostsWithBLOBs> excerptList = getArticleExcerptListByFilter(request, filter); Map<String, Map<String, List<BlogPostsWithBLOBs>>> timeline = Maps.newLinkedHashMap(); for (BlogPostsWithBLOBs spost : excerptList) { Date postDate = spost.getPostDate(); DateTime dt = new DateTime(postDate.getTime()); String yearMonthKey = dt.monthOfYear().getAsText(Locale.ENGLISH) + "," + dt.getYearOfEra();////key May,2015? Map<String, List<BlogPostsWithBLOBs>> yearMonthPostMap = timeline.get(yearMonthKey); if (yearMonthPostMap == null) { yearMonthPostMap = Maps.newLinkedHashMap(); timeline.put(yearMonthKey, yearMonthPostMap); } String dayKey = "Day" + dt.getDayOfMonth(); List<BlogPostsWithBLOBs> dayPostList = yearMonthPostMap.get(dayKey); if (dayPostList == null) { dayPostList = Lists.newArrayList(); yearMonthPostMap.put(dayKey, dayPostList); } dayPostList.add(spost); } return timeline; }
From source file:com.sap.dirigible.runtime.metrics.TimeUtils.java
License:Open Source License
private static DateTime dateTimeCeiling(DateTime dt, Period p) { if (p.getYears() != 0) { return dt.yearOfEra().roundCeilingCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundCeilingCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundCeilingCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundCeilingCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundCeilingCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundCeilingCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundCeilingCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }//from w ww .j av a 2 s.c o m return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.core.impl.DateTimeService.java
License:Apache License
public DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }//w ww .j a v a2 s . co m return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.datetime.DateTimeService.java
License:Apache License
public static DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }/* w ww. j a va 2 s. c om*/ return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.tasks.api.AbstractTrigger.java
License:Apache License
protected DateTime getExecutionTime(long time, Duration duration) { DateTime dt = new DateTime(time); Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }/*from w w w .j a v a2 s. c om*/ return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.mifos.test.acceptance.framework.loan.RedoLoanDisbursalEntryPage.java
License:Open Source License
public void enterDisbursementDate(DateTime disbursalDate) { selenium.type("disbursementDateDD", Integer.valueOf(disbursalDate.getDayOfMonth()).toString()); selenium.type("disbursementDateMM", Integer.valueOf(disbursalDate.getMonthOfYear()).toString()); selenium.type("disbursementDateYY", Integer.valueOf(disbursalDate.getYearOfEra()).toString()); selenium.fireEvent("disbursementDateYY", "blur"); }
From source file:org.mifos.test.acceptance.framework.testhelpers.SavingsProductHelper.java
License:Open Source License
/** * This method return a fully useable parameter object for the type of deposit (mandatory/voluntary) * and applicable for (clients/groups/centers). * @return Parameters like noted above.// ww w . j a v a 2s . c o m * @param typeOfDeposits * @param applicableFor */ public SavingsProductParameters getGenericSavingsProductParameters(DateTime startDate, int typeOfDeposits, int applicableFor) { SavingsProductParameters params = new SavingsProductParameters(); params.setProductInstanceName("Savings product test" + StringUtil.getRandomString(3)); params.setShortName(StringUtil.getRandomString(4)); params.setProductCategory(SavingsProductParameters.OTHER); params.setStartDateDD(Integer.valueOf(startDate.getDayOfMonth()).toString()); params.setStartDateMM(Integer.valueOf(startDate.getMonthOfYear()).toString()); params.setStartDateYYYY(Integer.valueOf(startDate.getYearOfEra()).toString()); params.setApplicableFor(applicableFor); params.setTypeOfDeposits(typeOfDeposits); // these two settings are not required in all configurations // but they're good to have anyway params.setMandatoryAmount("10"); params.setAmountAppliesTo(SavingsProductParameters.WHOLE_GROUP); params.setInterestRate("4"); params.setBalanceUsedForInterestCalculation(SavingsProductParameters.AVERAGE_BALANCE); params.setDaysOrMonthsForInterestCalculation(SavingsProductParameters.MONTHS); params.setNumberOfDaysOrMonthsForInterestCalculation("3"); params.setFrequencyOfInterestPostings("6"); params.setGlCodeForDeposit("24101 - Mandatory Savings Accounts"); params.setGlCodeForInterest("41102 - Interest on clients mandatory savings"); return params; }
From source file:org.mifos.ui.core.controller.GeneralProductBeanAssembler.java
License:Open Source License
private void defaultStartDateToToday(GeneralProductBean formBean) { DateTime today = new DateTime(); formBean.setStartDateDay(today.getDayOfMonth()); formBean.setStartDateMonth(today.getMonthOfYear()); formBean.setStartDateYear(Integer.valueOf(today.getYearOfEra()).toString()); }
From source file:org.mifos.ui.core.controller.SystemUserController.java
License:Open Source License
public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) { OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue()); formBean.setOfficeId(officeId);// w w w .j a v a 2 s . co m formBean.setOfficeName(selectedOffice.getName()); MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields(); formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1()); formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2()); formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3()); formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity()); formBean.getAddress().setStateHidden(dtoFields.isHideSystemState()); formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry()); formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode()); DefinePersonnelDto userRefData = this.personnelServiceFacade .retrieveInfoForNewUserDefinition(officeId.shortValue()); Map<String, String> genderOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getGenderList()) { genderOptions.put(option.getId().toString(), option.getName()); } formBean.setGenderOptions(genderOptions); Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getMaritalStatusList()) { maritalStatusOptions.put(option.getId().toString(), option.getName()); } formBean.setMaritalStatusOptions(maritalStatusOptions); Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getLanguageList()) { preferredLanguageOptions.put(option.getId().toString(), option.getName()); } formBean.setPreferredLanguageOptions(preferredLanguageOptions); Map<String, String> userTitleOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getTitleList()) { userTitleOptions.put(option.getId().toString(), option.getName()); } formBean.setUserTitleOptions(userTitleOptions); Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getPersonnelLevelList()) { userHierarchyOptions.put(option.getId().toString(), option.getName()); } formBean.setUserHierarchyOptions(userHierarchyOptions); Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getRolesList()) { availableRolesOptions.put(option.getId().toString(), option.getName()); } formBean.setAvailableRolesOptions(availableRolesOptions); formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>()); DateTime today = new DateTime(); formBean.setMfiJoiningDateDay(today.getDayOfMonth()); formBean.setMfiJoiningDateMonth(today.getMonthOfYear()); formBean.setMfiJoiningDateYear(today.getYearOfEra()); return formBean; }