Package java.time

Examples of java.time.LocalDate


    @Override
    public void start(Stage stage) throws Exception {
        /*
         * Properties of any type can be easily injected.
         */
        LocalDate date = LocalDate.of(4242, Month.JULY, 21);
        Map<Object, Object> customProperties = new HashMap<>();
        customProperties.put("date", date);
        /*
         * any function which accepts an Object as key and returns
         * and return an Object as result can be used as source.
View Full Code Here


     *
     * @param year  the year to create a transition for, not null
     * @return the transition instance, not null
     */
    public ZoneOffsetTransition createTransition(int year) {
        LocalDate date;
        if (dom < 0) {
            date = LocalDate.of(year, month, month.length(IsoChronology.INSTANCE.isLeapYear(year)) + 1 + dom);
            if (dow != null) {
                date = date.with(previousOrSame(dow));
            }
        } else {
            date = LocalDate.of(year, month, dom);
            if (dow != null) {
                date = date.with(nextOrSame(dow));
            }
        }
        if (timeEndOfDay) {
            date = date.plusDays(1);
        }
        LocalDateTime localDT = LocalDateTime.of(date, time);
        LocalDateTime transition = timeDefinition.createDateTime(localDT, standardOffset, offsetBefore);
        return new ZoneOffsetTransition(transition, offsetBefore, offsetAfter);
    }
View Full Code Here

        LocalGregorianCalendar.Date jdate = JapaneseChronology.JCAL.newCalendarDate(null);
        jdate.setEra(era.getPrivateEra()).setDate(yearOfEra, month, dayOfMonth);
        if (!JapaneseChronology.JCAL.validate(jdate)) {
            throw new DateTimeException("year, month, and day not valid for Era");
        }
        LocalDate date = LocalDate.of(jdate.getNormalizedYear(), month, dayOfMonth);
        return new JapaneseDate(era, yearOfEra, date);
    }
View Full Code Here

        }
        JapaneseChronology.JCAL.normalize(jdate);
        if (era.getPrivateEra() != jdate.getEra() || yearOfEra != jdate.getYear()) {
            throw new DateTimeException("Invalid parameters");
        }
        LocalDate localdate = LocalDate.of(jdate.getNormalizedYear(),
                                      jdate.getMonth(), jdate.getDayOfMonth());
        return new JapaneseDate(era, yearOfEra, localdate);
    }
View Full Code Here

   * @return
   */
  public static LocalDate createLocalDateFromCalendar(Calendar calendar)
  {
    if (calendar == null) return null;
    LocalDate lLocalDate = LocalDate.of(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DATE));
    return lLocalDate;
  }
View Full Code Here

   */
  public static LocalDate createLocaleDateFromDate(Date date) {
    if (date == null) {
      return null;
    }
    LocalDate lLocalDate = LocalDateTime.ofInstant( date.toInstant(), ZoneId.systemDefault() ).toLocalDate();
    return lLocalDate;
  }
View Full Code Here

    calendars.addListener( (ListChangeListener.Change<? extends Calendar> change) -> {
      while (change.next())
      {
        for (Calendar lCalendar : change.getRemoved())
        {
          LocalDate lLocalDate = createLocalDateFromCalendar(lCalendar);
          if (localDates.contains(lLocalDate)) {
            localDates.remove(lLocalDate);
          }       
        }
        for (Calendar lCalendar : change.getAddedSubList())
        {
          LocalDate lLocalDate = createLocalDateFromCalendar(lCalendar);
          if (localDates.contains(lLocalDate) == false) {
            localDates.add(lLocalDate);
          }
        }
      }
View Full Code Here

    }
    final private DateTimeFormatter dateTimeFormatter;
   
    @Override
    public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
      LocalDate lLocalDate = createLocaleDateFromDate(date);
      String s = this.dateTimeFormatter.format( lLocalDate );
      toAppendTo.append(s);
      return toAppendTo;
    }
View Full Code Here

      return toAppendTo;
    }

    @Override
    public Date parse(String source, ParsePosition pos) {
      LocalDate lLocalDate = LocalDate.parse(source, this.dateTimeFormatter);
      Date lDate = createDateFromLocalDate(lLocalDate);
      pos.setIndex(source.length()); // otherwise DateFormat will thrown an exception
      return lDate;
    }
View Full Code Here

    @Test
    public void testStringToLocalDate() {
        String dateTimeAsString = "01.01.2014";
        Target target = new Target();
        target.setLocalDate( dateTimeAsString );
        LocalDate sourceDate =
                        LocalDate.of( 2014, 1, 1 );

        Source src = SourceTargetMapper.INSTANCE.targetToSourceLocalDateMapped( target );
        assertThat( src ).isNotNull();
        assertThat( src.getLocalDate() ).isEqualTo( sourceDate );
View Full Code Here

TOP

Related Classes of java.time.LocalDate

Copyright © 2018 www.massapicom. 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.