Package java.time

Examples of java.time.LocalDateTime


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


      return toAppendTo;
    }

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

  {
    // default value is null
    Assert.assertNull( localDateTimePicker.getLocalDateTime());

    // set a value
    final LocalDateTime lLocalDateTime = LocalDateTime.of(2013, 01, 01, 12, 34, 56);
    TestUtil.runThenWaitForPaintPulse( () -> {
      localDateTimePicker.setLocalDateTime( lLocalDateTime );
    });
    Assert.assertEquals("2013-01-01T12:34:56", localDateTimePicker.getLocalDateTime().toString());
View Full Code Here

    @Test
    public void testStringToLocalDateTime() {
        String dateTimeAsString = "01.01.2014 00:00";
        Target target = new Target();
        target.setLocalDateTime( dateTimeAsString );
        LocalDateTime sourceDateTime =
                        LocalDateTime.of( 2014, 1, 1, 0, 0, 0 );

        Source src = SourceTargetMapper.INSTANCE.targetToSourceLocalDateTimeMapped( target );
        assertThat( src ).isNotNull();
        assertThat( src.getLocalDateTime() ).isEqualTo( sourceDateTime );
View Full Code Here

    @Test
    public void testLocalDateTimeToDateMapping() {
        TimeZone.setDefault( TimeZone.getTimeZone( "UTC" ) );
        Source source = new Source();
        LocalDateTime dateTime = LocalDateTime.of( 2014, 1, 1, 0, 0 );
        source.setForDateConversionWithLocalDateTime( dateTime );

        Target target = SourceTargetMapper.INSTANCE.sourceToTargetDefaultMapping( source );

        assertThat( target.getForDateConversionWithLocalDateTime() ).isNotNull();

        Calendar instance = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) );
        instance.setTimeInMillis( target.getForDateConversionWithLocalDateTime().getTime() );

        assertThat( instance.get( Calendar.YEAR ) ).isEqualTo( dateTime.getYear() );
        assertThat( instance.get( Calendar.MONTH ) ).isEqualTo( dateTime.getMonthValue() - 1 );
        assertThat( instance.get( Calendar.DATE ) ).isEqualTo( dateTime.getDayOfMonth() );
        assertThat( instance.get( Calendar.MINUTE ) ).isEqualTo( dateTime.getMinute() );
        assertThat( instance.get( Calendar.HOUR ) ).isEqualTo( dateTime.getHour() );

        source = SourceTargetMapper.INSTANCE.targetToSource( target );

        assertThat( source.getForDateConversionWithLocalDateTime() ).isEqualTo( dateTime );
View Full Code Here

        if (lexer.token() == JSONToken.LITERAL_STRING) {
            String text = lexer.stringVal();
            lexer.nextToken();

            if (type == LocalDateTime.class) {
                LocalDateTime localDateTime = LocalDateTime.parse(text);

                return (T) localDateTime;
            } else if (type == LocalDate.class) {
                LocalDate localDate = LocalDate.parse(text);
View Full Code Here

        Date dt = (Date) value[0];
        if (dt == null) {
            return null;
        }
        ZoneId zone = ZoneId.of((String) value[1]);
        LocalDateTime ldt = LocalDateTime.from(dt.toInstant());
        return ZonedDateTime.of(ldt, zone);
    }
View Full Code Here

        Date dt = (Date) value[0];
        if (dt == null) {
            return null;
        }
        ZoneOffset zone = ZoneOffset.of((String) value[1]);
        LocalDateTime ldt = LocalDateTime.ofInstant(dt.toInstant(), zone);
        return OffsetDateTime.of(ldt, zone);
    }
View Full Code Here

            if (orderItems.isEmpty()) {
                return tasks;
            }

            final LocalDateTime minDeadLine = orderItems.get(0).getDeadLine();
            final LocalDateTime maxDeadLine = orderItems.get(orderItems.size() - 1).getDeadLine();
            final LocalDateTime now = LocalDateTime.now();

            final long wholeIntervalInMinutes = MINUTES.between(minDeadLine, maxDeadLine);

            orderItems.forEach(order -> {
                int completed = (int) (100 * MINUTES.between(minDeadLine, order.getDeadLine()) / wholeIntervalInMinutes);
View Full Code Here

    public void all_not_null() throws Exception {
        try (PersistenceSession session = persistenceManager.createSession()) {
            JavatimeConvertEntity inst = new JavatimeConvertEntity();
            inst.setId(99);
            OffsetDateTime dt = OffsetDateTime.ofInstant(new Date().toInstant(), ZoneOffset.of("+0200"));
            LocalDateTime ldt = dt.toLocalDateTime();
            LocalDate ld = ldt.toLocalDate();
            inst.setDateTime(dt);
            inst.setLocalDate(ld);
            inst.setLocalDateTime(ldt);
            session.insert(inst);
View Full Code Here

TOP

Related Classes of java.time.LocalDateTime

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.