Examples of ChronoLocalDate


Examples of java.time.chrono.ChronoLocalDate

    assertFalse( constraint.isValid( past, null ), "Past MinguoDate '" + past + "' validated as future.");
  }

  @Test
  public void testIsValidForThaiBuddhistDate() {
    ChronoLocalDate future = ThaiBuddhistDate.now().plus( 1, DAYS );
    ChronoLocalDate past = ThaiBuddhistDate.now().minus( 1, DAYS );

    assertTrue( constraint.isValid( future, null ), "Future ThaiBuddhistDate '" + future + "' fails validation.");
    assertFalse( constraint.isValid( past, null ), "Past ThaiBuddhistDate '" + past + "' validated as future.");
  }
View Full Code Here

Examples of java.time.chrono.ChronoLocalDate

    assertTrue( constraint.isValid( null, null ), "null fails validation." );
  }

  @Test
  public void testIsValidForLocalDate() {
    ChronoLocalDate future = LocalDate.now().plusDays( 1 );
    ChronoLocalDate past = LocalDate.now().minusDays( 1 );

    assertTrue( constraint.isValid( past, null ), "Past LocalDate '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future LocalDate '" + future + "' validated as past.");
  }
View Full Code Here

Examples of java.time.chrono.ChronoLocalDate

    assertFalse( constraint.isValid( future, null ), "Future LocalDate '" + future + "' validated as past.");
  }

  @Test
  public void testIsValidForJapaneseDate() {
    ChronoLocalDate future = JapaneseDate.now().plus( 1, DAYS );
    ChronoLocalDate past = JapaneseDate.now().minus( 1, DAYS );

    assertTrue( constraint.isValid( past, null ), "Past JapaneseDate '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future JapaneseDate '" + future + "' validated as past.");
  }
View Full Code Here

Examples of java.time.chrono.ChronoLocalDate

    assertFalse( constraint.isValid( future, null ), "Future JapaneseDate '" + future + "' validated as past.");
  }

  @Test
  public void testIsValidForHijrahDate() {
    ChronoLocalDate future = HijrahDate.now().plus( 1, DAYS );
    ChronoLocalDate past = HijrahDate.now().minus( 1, DAYS );

    assertTrue( constraint.isValid( past, null ), "Past HijrahDate '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future HijrahDate '" + future + "' validated as past.");
  }
View Full Code Here

Examples of java.time.chrono.ChronoLocalDate

    assertFalse( constraint.isValid( future, null ), "Future HijrahDate '" + future + "' validated as past.");
  }

  @Test
  public void testIsValidForMinguoDate() {
    ChronoLocalDate future = MinguoDate.now().plus( 1, DAYS );
    ChronoLocalDate past = MinguoDate.now().minus( 1, DAYS );

    assertTrue( constraint.isValid( past, null ), "Past MinguoDate '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future MinguoDate '" + future + "' validated as past.");
  }
View Full Code Here

Examples of java.time.chrono.ChronoLocalDate

    assertFalse( constraint.isValid( future, null ), "Future MinguoDate '" + future + "' validated as past.");
  }

  @Test
  public void testIsValidForThaiBuddhistDate() {
    ChronoLocalDate future = ThaiBuddhistDate.now().plus( 1, DAYS );
    ChronoLocalDate past = ThaiBuddhistDate.now().minus( 1, DAYS );

    assertTrue( constraint.isValid( past, null ), "Past ThaiBuddhistDate '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future ThaiBuddhistDate '" + future + "' validated as past.");
  }
View Full Code Here

Examples of org.threeten.bp.chrono.ChronoLocalDate

            int sow = weekDef.getFirstDayOfWeek().getValue();
            int isoDow = temporal.get(DAY_OF_WEEK);
            int dow = Jdk8Methods.floorMod(isoDow - sow, 7) + 1;
            long woy = localizedWeekOfYear(temporal, dow);
            if (woy == 0) {
                ChronoLocalDate previous = Chronology.from(temporal).date(temporal).minus(1, ChronoUnit.WEEKS);
                return (int) localizedWeekOfYear(previous, dow) + 1;
            } else if (woy >= 53) {
                int offset = startOfWeekOffset(temporal.get(DAY_OF_YEAR), dow);
                int year = temporal.get(YEAR);
                int yearLen = Year.isLeap(year) ? 366 : 365;
View Full Code Here

Examples of org.threeten.bp.chrono.ChronoLocalDate

                }
                Chronology chrono = Chronology.from(partialTemporal)// defaults to ISO
                int isoDow = DAY_OF_WEEK.checkValidIntValue(fieldValues.get(DAY_OF_WEEK));
                int dow = Jdk8Methods.floorMod(isoDow - sow, 7) + 1;
                final int wby = range().checkValidIntValue(fieldValues.get(this), this);
                ChronoLocalDate date;
                long days;
                if (resolverStyle == ResolverStyle.LENIENT) {
                    date = chrono.date(wby, 1, weekDef.getMinimalDaysInFirstWeek());
                    long wowby = fieldValues.get(weekDef.weekOfWeekBasedYear);
                    int dateDow = localizedDayOfWeek(date, sow);
                    long weeks = wowby - localizedWeekOfYear(date, dateDow);
                    days = weeks * 7 + (dow - dateDow);
                } else {
                    date = chrono.date(wby, 1, weekDef.getMinimalDaysInFirstWeek());
                    long wowby = weekDef.weekOfWeekBasedYear.range().checkValidIntValue(
                                    fieldValues.get(weekDef.weekOfWeekBasedYear), weekDef.weekOfWeekBasedYear);
                    int dateDow = localizedDayOfWeek(date, sow);
                    long weeks = wowby - localizedWeekOfYear(date, dateDow);
                    days = weeks * 7 + (dow - dateDow);
                }
                date = date.plus(days, DAYS);
                if (resolverStyle == ResolverStyle.STRICT) {
                    if (date.getLong(this) != fieldValues.get(this)) {
                        throw new DateTimeException("Strict mode rejected date parsed to a different year");
                    }
                }
                fieldValues.remove(this);
                fieldValues.remove(weekDef.weekOfWeekBasedYear);
                fieldValues.remove(DAY_OF_WEEK);
                return date;
            }
           
            if (fieldValues.containsKey(YEAR) == false) {
                return null;
            }
            int isoDow = DAY_OF_WEEK.checkValidIntValue(fieldValues.get(DAY_OF_WEEK));
            int dow = Jdk8Methods.floorMod(isoDow - sow, 7) + 1;
            int year = YEAR.checkValidIntValue(fieldValues.get(YEAR));
            Chronology chrono = Chronology.from(partialTemporal)// defaults to ISO
            if (rangeUnit == MONTHS) {  // week-of-month
                if (fieldValues.containsKey(MONTH_OF_YEAR) == false) {
                    return null;
                }
                final long value = fieldValues.remove(this);
                ChronoLocalDate date;
                long days;
                if (resolverStyle == ResolverStyle.LENIENT) {
                    long month = fieldValues.get(MONTH_OF_YEAR);
                    date = chrono.date(year, 1, 1);
                    date = date.plus(month - 1, MONTHS);
                    int dateDow = localizedDayOfWeek(date, sow);
                    long weeks = value - localizedWeekOfMonth(date, dateDow);
                    days = weeks * 7 + (dow - dateDow);
                } else {
                    int month = MONTH_OF_YEAR.checkValidIntValue(fieldValues.get(MONTH_OF_YEAR));
                    date = chrono.date(year, month, 8);
                    int dateDow = localizedDayOfWeek(date, sow);
                    int wom = range.checkValidIntValue(value, this);
                    long weeks = wom - localizedWeekOfMonth(date, dateDow);
                    days = weeks * 7 + (dow - dateDow);
                }
                date = date.plus(days, DAYS);
                if (resolverStyle == ResolverStyle.STRICT) {
                    if (date.getLong(MONTH_OF_YEAR) != fieldValues.get(MONTH_OF_YEAR)) {
                        throw new DateTimeException("Strict mode rejected date parsed to a different month");
                    }
                }
                fieldValues.remove(this);
                fieldValues.remove(YEAR);
                fieldValues.remove(MONTH_OF_YEAR);
                fieldValues.remove(DAY_OF_WEEK);
                return date;
            } else if (rangeUnit == YEARS) {  // week-of-year
                final long value = fieldValues.remove(this);
                ChronoLocalDate date = chrono.date(year, 1, 1);
                long days;
                if (resolverStyle == ResolverStyle.LENIENT) {
                    int dateDow = localizedDayOfWeek(date, sow);
                    long weeks = value - localizedWeekOfYear(date, dateDow);
                    days = weeks * 7 + (dow - dateDow);
                } else {
                    int dateDow = localizedDayOfWeek(date, sow);
                    int woy = range.checkValidIntValue(value, this);
                    long weeks = woy - localizedWeekOfYear(date, dateDow);
                    days = weeks * 7 + (dow - dateDow);
                }
                date = date.plus(days, DAYS);
                if (resolverStyle == ResolverStyle.STRICT) {
                    if (date.getLong(YEAR) != fieldValues.get(YEAR)) {
                        throw new DateTimeException("Strict mode rejected date parsed to a different year");
                    }
                }
                fieldValues.remove(this);
                fieldValues.remove(YEAR);
View Full Code Here

Examples of org.threeten.bp.chrono.ChronoLocalDate

    }

    private static void newPackagePluggable() {
        Chronology chrono = MinguoChronology.INSTANCE;

        ChronoLocalDate date = chrono.dateNow();
        System.out.printf("now: %s%n", date);

        date = date.with(DAY_OF_MONTH, 1);
        System.out.printf("first of month: %s%n", date);

        int month = (int) date.get(ChronoField.MONTH_OF_YEAR);
        date = date.with(DAY_OF_WEEK, 1);
        System.out.printf("start of first week: %s%n", date);

        while (date.get(ChronoField.MONTH_OF_YEAR) <= month) {
            String row = "";
            for (int i = 0; i < 7; i++) {
                row += date.get(ChronoField.DAY_OF_MONTH) + " ";
                date = date.plus(1, ChronoUnit.DAYS);
            }
            System.out.println(row);
        }
    }
View Full Code Here

Examples of org.threeten.bp.chrono.ChronoLocalDate

     */
    static void example1() {
        System.out.printf("Available Calendars%n");

        // Print the Minguo date
        ChronoLocalDate now1 = MinguoChronology.INSTANCE.dateNow();
        int day = now1.get(ChronoField.DAY_OF_MONTH);
        int dow = now1.get(ChronoField.DAY_OF_WEEK);
        int month = now1.get(ChronoField.MONTH_OF_YEAR);
        int year = now1.get(ChronoField.YEAR);
        System.out.printf("  Today is %s %s %d-%s-%d%n", now1.getChronology().getId(),
                DayOfWeek.of(dow), year, month, day);

        // Print today's date and the last day of the year for the Minguo Calendar.
        ChronoLocalDate first = now1
                .with(ChronoField.DAY_OF_MONTH, 1)
                .with(ChronoField.MONTH_OF_YEAR, 1);
        ChronoLocalDate last = first
                .plus(1, ChronoUnit.YEARS)
                .minus(1, ChronoUnit.DAYS);
        System.out.printf("  1st of year: %s; end of year: %s%n", first, last);

        // Enumerate the list of available calendars and print today for each
        LocalDate  before = LocalDate.of(-500, 1, 1);
        Set<Chronology> chronos = Chronology.getAvailableChronologies();
        for (Chronology chrono : chronos) {
            ChronoLocalDate date = chrono.dateNow();
            ChronoLocalDate date2 = chrono.date(before);
            System.out.printf("   %20s: %22s, %22s%n", chrono.getId(), date, date2);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.