org.joda.time.LocalDate#getYear ( )源码实例Demo

下面列出了org.joda.time.LocalDate#getYear ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: NCalendar   文件: CalendarUtil.java
/**
 * 获取CalendarDate  CalendarDate包含需要显示的信息 农历,节气等
 * @param localDate
 * @return
 */
public static CalendarDate getCalendarDate(LocalDate localDate) {
    CalendarDate calendarDate = new CalendarDate();
    int solarYear = localDate.getYear();
    int solarMonth = localDate.getMonthOfYear();
    int solarDay = localDate.getDayOfMonth();
    Lunar lunar = LunarUtil.getLunar(solarYear, solarMonth, solarDay);

    if (solarYear != 1900) {
        calendarDate.lunar = lunar;
        calendarDate.localDate = localDate;
        calendarDate.solarTerm = SolarTermUtil.getSolatName(solarYear, (solarMonth < 10 ? ("0" + solarMonth) : (solarMonth + "")) + solarDay);
        calendarDate.solarHoliday = HolidayUtil.getSolarHoliday(solarYear, solarMonth, solarDay);
        calendarDate.lunarHoliday = HolidayUtil.getLunarHoliday(lunar.lunarYear, lunar.lunarMonth, lunar.lunarDay);
    }

    return calendarDate;
}
 
源代码2 项目: dsl-json   文件: JodaTimeConverter.java
public static void serialize(final LocalDate value, final JsonWriter sw) {
	final int year = value.getYear();
	if (year < 0) {
		throw new SerializationException("Negative dates are not supported.");
	} else if (year > 9999) {
		sw.writeByte(JsonWriter.QUOTE);
		NumberConverter.serialize(year, sw);
		sw.writeByte((byte)'-');
		NumberConverter.serialize(value.getMonthOfYear(), sw);
		sw.writeByte((byte)'-');
		NumberConverter.serialize(value.getDayOfMonth(), sw);
		sw.writeByte(JsonWriter.QUOTE);
		return;
	}
	final byte[] buf = sw.ensureCapacity(12);
	final int pos = sw.size();
	buf[pos] = '"';
	NumberConverter.write4(year, buf, pos + 1);
	buf[pos + 5] = '-';
	NumberConverter.write2(value.getMonthOfYear(), buf, pos + 6);
	buf[pos + 8] = '-';
	NumberConverter.write2(value.getDayOfMonth(), buf, pos + 9);
	buf[pos + 11] = '"';
	sw.advance(12);
}
 
@Override
public Stream<User> getMembers() {
    Set<User> users = new HashSet<User>();
    for (Registration registration : degree.getRegistrationsSet()) {
        if (registration.hasConcluded()) {
            LocalDate conclusionDate = getConclusionDate(degree, registration);
            if (conclusionDate != null
                    && (conclusionDate.getYear() == conclusionYear.getEndCivilYear() || conclusionDate.getYear() == conclusionYear
                            .getBeginCivilYear())) {
                User user = registration.getPerson().getUser();
                if (user != null) {
                    users.add(user);
                }
            }
        }
    }
    return users.stream();
}
 
源代码4 项目: estatio   文件: BudgetRepository.java
public String validateNewBudget(
        final Property property,
        final LocalDate startDate,
        final LocalDate endDate) {

    if (startDate == null) {
        return "Start date is mandatory";
    }

    if (!new LocalDateInterval(startDate, endDate).isValid()) {
        return "End date can not be before start date";
    }

    if (endDate!=null && endDate.getYear()!=startDate.getYear()){
        return "A budget should have an end date in the same year as start date";
    }

    for (Budget budget : this.findByProperty(property)) {
        if (budget.getInterval().overlaps(new LocalDateInterval(startDate, endDate))) {
            return "A budget cannot overlap an existing budget.";
        }
    }

    return null;
}
 
源代码5 项目: prayer-times-android   文件: WebTimes.java
private void cleanTimes() {
    Set<String> keys = new ArraySet<>();
    keys.addAll(times.keySet());
    LocalDate date = LocalDate.now();
    int y = date.getYear();
    int m = date.getMonthOfYear();
    List<String> remove = new ArrayList<>();
    for (String key : keys) {
        if (key == null)
            continue;
        int year = FastParser.parseInt(key.substring(0, 4));
        if (year < y)
            keys.remove(key);
        else if (year == y) {
            int month = FastParser.parseInt(key.substring(5, 7));
            if (month < m)
                remove.add(key);
        }
    }
    times.removeAll(remove);

}
 
protected String getFormattedDate(LocalDate date) {
    final int dayOfMonth = date.getDayOfMonth();
    final String month = date.toString("MMMM", getLocale());
    final int year = date.getYear();

    return new StringBuilder()
            .append(dayOfMonth)
            .append( (getLocale().equals(LocaleUtils.PT) ? EMPTY_STR : getDayOfMonthSuffixOfDate(dayOfMonth)) )
            .append(SINGLE_SPACE)
            .append(BundleUtil.getString(Bundle.APPLICATION, getLocale(), "label.of"))
            .append(SINGLE_SPACE)
            .append( (getLocale().equals(LocaleUtils.PT)) ? month.toLowerCase() : month )
            .append(SINGLE_SPACE)
            .append(BundleUtil.getString(Bundle.APPLICATION, getLocale(), "label.of"))
            .append(SINGLE_SPACE)
            .append(year)
            .toString();
}
 
@Override
public boolean isMember(User user) {
    if (user == null || user.getPerson().getStudent() == null) {
        return false;
    }
    for (final Registration registration : user.getPerson().getStudent().getRegistrationsSet()) {
        if (registration.isConcluded() && registration.getDegree().equals(degree)) {
            LocalDate conclusionDate = getConclusionDate(registration.getDegree(), registration);
            if (conclusionDate != null
                    && (conclusionDate.getYear() == conclusionYear.getEndCivilYear() || conclusionDate.getYear() == conclusionYear
                            .getBeginCivilYear())) {
                return true;
            }
            return false;
        }
    }
    return false;
}
 
源代码8 项目: googlecalendar   文件: MainActivity.java
@Subscribe
public void onEvent(MonthChange event) {


   if (!isAppBarExpanded()){

       LocalDate localDate=new LocalDate();
       String year=event.getMessage().getYear()==localDate.getYear()?"":event.getMessage().getYear()+"";
       monthname.setText(event.getMessage().toString("MMMM")+" "+year);

       long diff=System.currentTimeMillis()-lasttime;
       boolean check=diff>600;
       if (check&&event.mdy>0){
           monthname.setTranslationY(35);
           mArrowImageView.setTranslationY(35);
           lasttime=System.currentTimeMillis();
           monthname.animate().translationY(0).setDuration(200).start();
           mArrowImageView.animate().translationY(0).setDuration(200).start();

       }
       else if (check&&event.mdy<0){

           monthname.setTranslationY(-35);
           mArrowImageView.setTranslationY(-35);
           lasttime=System.currentTimeMillis();
           monthname.animate().translationY(0).setDuration(200).start();
           mArrowImageView.animate().translationY(0).setDuration(200).start();
       }



   }

}
 
源代码9 项目: googlecalendar   文件: MainActivity.java
@Override
public long getHeaderId(int position) {


    if (eventalllist.get(position).getType()==1)return position;
    else if (eventalllist.get(position).getType()==3)return position;
   else if (eventalllist.get(position).getType()==100)return position;
    else if (eventalllist.get(position).getType()==200)return position;
    LocalDate localDate=eventalllist.get(position).getLocalDate();
    String uniquestr=""+localDate.getDayOfMonth()+localDate.getMonthOfYear()+localDate.getYear();
    return Long.parseLong(uniquestr);

}
 
源代码10 项目: reladomo   文件: PYETopLevelLoaderFactory.java
protected Timestamp shiftBusinessDate(Timestamp businessDate)
{
    LocalDate localDate = new LocalDate(businessDate);
    int year = localDate.getYear();
    LocalDateTime pye = new LocalDateTime(year - 1, 12, 31, 23, 59, 0, 0);
    int dayOfWeek = pye.dayOfWeek().get();
    if (dayOfWeek > 5)
    {
        pye = pye.minusDays(dayOfWeek - 5);
    }
    return new Timestamp(pye.toDateTime().getMillis());
}
 
public double yearDiff(final LocalDate start, final LocalDate end, final PeriodCountBasis basis) {
    double diff = 0.0;

    switch (basis) {
    case ACT_ACT:
        final int startYear = start.getYear();
        final int endYear = end.getYear();
        if (startYear != endYear) {
            final LocalDate endOfStartYear = start.dayOfYear().withMaximumValue();
            final LocalDate startOfEndYear = end.withDayOfYear(1);

            final int diff1 = new Period(start, endOfStartYear, PeriodType.days()).getDays();
            final int diff2 = new Period(startOfEndYear, end, PeriodType.days()).getDays();
            diff = (diff1 + 1.0) / start.dayOfYear().getMaximumValue() + (endYear - startYear - 1.0)
                    + (double) diff2 / (double) end.dayOfYear().getMaximumValue();
        }
        break;

    case CONV_30_360:
    case CONV_360E_ISDA:
    case CONV_360E_ISMA:
    case ACT_360:
        diff = dayDiff(start, end, basis) / CalculatorConstants.YEAR_360_0;
        break;

    case ACT_365:
        diff = dayDiff(start, end, basis) / CalculatorConstants.YEAR_365_0;
        break;

    default:
        throw new UnsupportedOperationException("Sorry ACT_UST is not supported");
    }

    return diff;
}
 
源代码12 项目: fenixedu-academic   文件: RaidesPhdReportFile.java
@Override
public void renderReport(Spreadsheet spreadsheet) throws Exception {

    ExecutionYear executionYear = getExecutionYear();
    int civilYear = executionYear.getBeginCivilYear();
    fillSpreadsheet(spreadsheet);

    logger.info("BEGIN report for " + getDegreeType().getName().getContent());

    List<PhdIndividualProgramProcess> retrieveProcesses = retrieveProcesses(executionYear);

    for (PhdIndividualProgramProcess phdIndividualProgramProcess : retrieveProcesses) {
        if (phdIndividualProgramProcess.isConcluded()) {
            LocalDate conclusionDate = phdIndividualProgramProcess.getThesisProcess().getConclusionDate();

            if (conclusionDate == null
                    || (conclusionDate.getYear() != civilYear && conclusionDate.getYear() != civilYear - 1 && conclusionDate
                            .getYear() != civilYear + 1)) {
                continue;
            }
        }
        if (phdIndividualProgramProcess.isConcluded() || phdIndividualProgramProcess.getHasStartedStudies()) {

            reportRaidesGraduate(spreadsheet, phdIndividualProgramProcess, executionYear);
        }
    }
}
 
public boolean contains(LocalDate date) {
    LocalDate start = new LocalDate(date.getYear(), getMonthStart(), getDayStart());
    LocalDate end = new LocalDate(date.getYear(), getMonthEnd(), getDayEnd());

    if ((date.equals(start) || date.isAfter(start)) && (date.equals(end) || date.isBefore(end))) {
        return true;
    } else {
        return false;
    }
}
 
private int diffConv30v360(final LocalDate start, final LocalDate end) {
    int dayStart = start.getDayOfMonth();
    int dayEnd = end.getDayOfMonth();
    if (dayEnd == CalculatorConstants.MONTH_31_DAYS && dayStart >= CalculatorConstants.MONTH_30_DAYS) {
        dayEnd = CalculatorConstants.MONTH_30_DAYS;
    }
    if (dayStart == CalculatorConstants.MONTH_31_DAYS) {
        dayStart = CalculatorConstants.MONTH_30_DAYS;
    }
    return (end.getYear() - start.getYear()) * CalculatorConstants.YEAR_360 + (end.getMonthOfYear() - start.getMonthOfYear()) * CalculatorConstants.MONTH_30_DAYS + dayEnd - dayStart;
}
 
源代码15 项目: NCalendar   文件: CalendarUtil.java
/**
 * 两个日期是否同月
 */
public static boolean isEqualsMonth(LocalDate date1, LocalDate date2) {
    return date1.getYear() == date2.getYear() && date1.getMonthOfYear() == date2.getMonthOfYear();
}
 
源代码16 项目: prayer-times-android   文件: MalaysiaTimes.java
protected boolean sync() throws ExecutionException, InterruptedException {
    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;
    int m = ldate.getMonthOfYear();
    String[] split = getId().split("_");
    if (split.length < 2) delete();
    split[0] = URLEncoder.encode(split[0]);
    split[1] = URLEncoder.encode(split[1]);

    int x = 0;
    for (int M = m; (M <= (m + 1)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        String result = Ion.with(App.get())
                .load("http://www.e-solat.gov.my/web/waktusolat.php?negeri=" + split[0] + "&state=" + split[0] + "&zone=" + split[1] + "&year="
                        + Y + "&jenis=year&bulan=" + M)
                .setTimeout(3000)
                .userAgent(App.getUserAgent())
                .asString()
                .get();
        String date = result.substring(result.indexOf("muatturun"));
        date = date.substring(date.indexOf("year=") + 5);
        int year = Integer.parseInt(date.substring(0, 4));
        date = date.substring(date.indexOf("bulan") + 6);
        int month = Integer.parseInt(date.substring(0, date.indexOf("\"")));

        result = result.substring(result.indexOf("#7C7C7C"));
        result = result.substring(0, result.indexOf("<table"));
        FOR1:
        for (result = result.substring(result.indexOf("<tr", 1));
             result.contains("tr ");
             result = result.substring(result.indexOf("<tr", 1))) {
            try {
                result = result.substring(result.indexOf("<font") + 1);
                String d = extract(result);
                if (d.startsWith("Tarikh")) continue;
                int day = Integer.parseInt(d.substring(0, 2));
                result = result.substring(result.indexOf("<font") + 1);
                result = result.substring(result.indexOf("<font") + 1);
                String imsak = extract(result);
                result = result.substring(result.indexOf("<font") + 1);
                result = result.substring(result.indexOf("<font") + 1);
                String sun = extract(result);
                result = result.substring(result.indexOf("<font") + 1);
                String ogle = extract(result);
                result = result.substring(result.indexOf("<font") + 1);
                String ikindi = extract(result);
                result = result.substring(result.indexOf("<font") + 1);
                String aksam = extract(result);
                result = result.substring(result.indexOf("<font") + 1);
                String yatsi = extract(result);

                String[] array = new String[]{imsak, sun, ogle, ikindi, aksam, yatsi};
                for (int i = 0; i < array.length; i++) {
                    array[i] = array[i].replace(".", ":");
                    if (array[i].length() == 4) array[i] = "0" + array[i];
                    if (array[i].length() != 5) continue FOR1;
                }
                LocalDate localDate = new LocalDate(year, month, day);
                setTime(localDate, Vakit.FAJR, array[0]);
                setTime(localDate, Vakit.SUN, array[1]);
                setTime(localDate, Vakit.DHUHR, array[2]);
                setTime(localDate, Vakit.ASR, array[3]);
                setTime(localDate, Vakit.MAGHRIB, array[4]);
                setTime(localDate, Vakit.ISHAA, array[5]);
                x++;
            } catch (Exception ignore) {
            }
        }

    }


    return x > 25;
}
 
源代码17 项目: prayer-times-android   文件: MoroccoTimes.java
protected boolean sync() throws ExecutionException, InterruptedException {
    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;
    int m = ldate.getMonthOfYear();
    int x = 0;

    for (int M = m; (M <= (m + 1)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        String result = Ion.with(App.get())
                .load("http://www.habous.gov.ma/prieres/defaultmois.php?ville=" + getId() + "&mois=" + M)
                .userAgent(App.getUserAgent())
                .setTimeout(3000)
                .asString()
                .get();
        String temp = result.substring(result.indexOf("colspan=\"4\" class=\"cournt\""));
        temp = temp.substring(temp.indexOf(">") + 1);
        temp = temp.substring(0, temp.indexOf("<")).replace(" ", "");
        int month = Integer.parseInt(temp.substring(0, temp.indexOf("/")));
        int year = Integer.parseInt(temp.substring(temp.indexOf("/") + 1));
        result = result.substring(result.indexOf("<td>") + 4);
        result = result.replace(" ", "").replace("\t", "").replace("\n", "").replace("\r", "");
        String[] zeiten = result.split("<td>");
        for (int i = 0; i < zeiten.length; i++) {
            int day = Integer.parseInt(extract(zeiten[i]));
            String imsak = extract(zeiten[++i]);
            String gunes = extract(zeiten[++i]);
            String ogle = extract(zeiten[++i]);
            String ikindi = extract(zeiten[++i]);
            String aksam = extract(zeiten[++i]);
            String yatsi = extract(zeiten[++i]);

            LocalDate localDate = new LocalDate(year, month, day);
            setTime(localDate, Vakit.FAJR, imsak);
            setTime(localDate, Vakit.SUN, gunes);
            setTime(localDate, Vakit.DHUHR, ogle);
            setTime(localDate, Vakit.ASR, ikindi);
            setTime(localDate, Vakit.MAGHRIB, aksam);
            setTime(localDate, Vakit.ISHAA, yatsi);
            x++;
        }


    }


    return x > 25;
}
 
源代码18 项目: astor   文件: GJChronology.java
/**
 * Factory method returns instances of the GJ cutover chronology. Any
 * cutover date may be specified.
 *
 * @param zone  the time zone to use, null is default
 * @param gregorianCutover  the cutover to use, null means default
 * @param minDaysInFirstWeek  minimum number of days in first week of the year; default is 4
 */
public static synchronized GJChronology getInstance(
        DateTimeZone zone,
        ReadableInstant gregorianCutover,
        int minDaysInFirstWeek) {
    
    zone = DateTimeUtils.getZone(zone);
    Instant cutoverInstant;
    if (gregorianCutover == null) {
        cutoverInstant = DEFAULT_CUTOVER;
    } else {
        cutoverInstant = gregorianCutover.toInstant();
        LocalDate cutoverDate = new LocalDate(cutoverInstant.getMillis(), GregorianChronology.getInstance(zone));
        if (cutoverDate.getYear() <= 0) {
            throw new IllegalArgumentException("Cutover too early. Must be on or after 0001-01-01.");
        }
    }

    GJChronology chrono;
    synchronized (cCache) {
        ArrayList<GJChronology> chronos = cCache.get(zone);
        if (chronos == null) {
            chronos = new ArrayList<GJChronology>(2);
            cCache.put(zone, chronos);
        } else {
            for (int i = chronos.size(); --i >= 0;) {
                chrono = chronos.get(i);
                if (minDaysInFirstWeek == chrono.getMinimumDaysInFirstWeek() &&
                    cutoverInstant.equals(chrono.getGregorianCutover())) {
                    
                    return chrono;
                }
            }
        }
        if (zone == DateTimeZone.UTC) {
            chrono = new GJChronology
                (JulianChronology.getInstance(zone, minDaysInFirstWeek),
                 GregorianChronology.getInstance(zone, minDaysInFirstWeek),
                 cutoverInstant);
        } else {
            chrono = getInstance(DateTimeZone.UTC, cutoverInstant, minDaysInFirstWeek);
            chrono = new GJChronology
                (ZonedChronology.getInstance(chrono, zone),
                 chrono.iJulianChronology,
                 chrono.iGregorianChronology,
                 chrono.iCutoverInstant);
        }
        chronos.add(chrono);
    }
    return chrono;
}
 
public Set<String> validate() {

        final Set<String> result = new HashSet<String>();

        if (getConclusionGrade() == null || getConclusionYear() == null || getCountryOfResidence() == null
                || getGrantOwnerType() == null || getDislocatedFromPermanentResidence() == null || !isSchoolLevelValid()
                || !isHighSchoolLevelValid() || !isMaritalStatusValid() || !isProfessionalConditionValid()
                || !isProfessionTypeValid() || !isMotherSchoolLevelValid() || !isMotherProfessionTypeValid()
                || !isMotherProfessionalConditionValid() || !isFatherProfessionalConditionValid()
                || !isFatherProfessionTypeValid() || !isFatherSchoolLevelValid()
                || getCountryWhereFinishedPreviousCompleteDegree() == null || !isCountryWhereFinishedHighSchoolValid()
                || (getDegreeDesignation() == null && !isUnitFromRaidesListMandatory())
                || (getInstitution() == null && StringUtils.isEmpty(getInstitutionName()))) {
            result.add("error.CandidacyInformationBean.required.information.must.be.filled");
        }

        LocalDate now = new LocalDate();
        if (getConclusionYear() != null && now.getYear() < getConclusionYear()) {
            result.add("error.personalInformation.year.after.current");
        }

        if(getStudent().getPerson().getDateOfBirthYearMonthDay() == null) {
            result.add("error.personalInformation.date.of.birth.does.not.exist");
        }
        else {
            int birthYear = getStudent().getPerson().getDateOfBirthYearMonthDay().getYear();
            if (getConclusionYear() != null && getConclusionYear() < birthYear) {
                result.add("error.personalInformation.year.before.birthday");
            }

            if (getSchoolLevel() != null && !getSchoolLevel().isSchoolLevelBasicCycle() && !getSchoolLevel().isOther()
                    && getConclusionYear() != null && getConclusionYear() < birthYear + 15) {
                result.add("error.personalInformation.year.before.fifteen.years.old");
            }
        }

        if (isUnitFromRaidesListMandatory()) {
            if (getInstitution() == null) {
                result.add("error.personalInformation.required.institution");
            }
            if (getDegreeDesignation() == null) {
                result.add("error.personalInformation.required.degreeDesignation");
            }
        }

        if (getCountryOfResidence() != null) {
            if (getCountryOfResidence().isDefaultCountry() && getDistrictSubdivisionOfResidence() == null) {
                result.add("error.CandidacyInformationBean.districtSubdivisionOfResidence.is.required.for.default.country");
            }
            if (!getCountryOfResidence().isDefaultCountry()
                    && (getDislocatedFromPermanentResidence() == null || !getDislocatedFromPermanentResidence())) {
                result.add("error.CandidacyInformationBean.foreign.students.must.select.dislocated.option");
            }
        }

        if (getDislocatedFromPermanentResidence() != null && getDislocatedFromPermanentResidence()
                && getSchoolTimeDistrictSubdivisionOfResidence() == null) {
            result.add("error.CandidacyInformationBean.schoolTimeDistrictSubdivisionOfResidence.is.required.for.dislocated.students");
        }

        if (getSchoolLevel() != null && getSchoolLevel() == SchoolLevelType.OTHER && StringUtils.isEmpty(getOtherSchoolLevel())) {
            result.add("error.CandidacyInformationBean.other.school.level.description.is.required");
        }

        if (isUnitFromRaidesListMandatory() && hasRaidesDegreeDesignation()
                && !getRaidesDegreeDesignation().getInstitutionUnitSet().contains(getInstitution())) {
            result.add("error.CandidacyInformationBean.designation.must.match.institution");
        }

        if (getGrantOwnerType() != null && getGrantOwnerType() == GrantOwnerType.OTHER_INSTITUTION_GRANT_OWNER
                && getGrantOwnerProvider() == null) {
            result.add("error.CandidacyInformationBean.grantOwnerProviderInstitutionUnitName.is.required.for.other.institution.grant.ownership");
        }

        return result;

    }
 
源代码20 项目: estatio   文件: PaymentLineExportV1.java
private int toYearPeriod(final LocalDate date) {
    return date.getYear()*100+ date.getMonthOfYear();
}