Package org.joda.time

Examples of org.joda.time.LocalDate


    @Test
    public void givenLocalDateTypeWhenConvertingToJsonExpectValidString()
        throws Exception
    {
        JSONObjectSerializer serializer = new JSONObjectSerializer();
        serializer.serialize( new LocalDate( "2020-03-04" ), underTest );
        Object value = serializer.getRoot();
        assertEquals( "2020-03-04", value.toString());
    }
View Full Code Here


    @Test
    public void givenLocalDateTypeWhenConvertingFromJsonExpectValidLocalDate()
        throws Exception
    {
        Object value = new JSONDeserializer( null ).deserialize( "2020-03-04", underTest );
        assertEquals( new LocalDate("2020-03-04"), value);
    }
View Full Code Here

            // given
            assertThat(container().titleOf(toDoItem), containsString("due by " + dueBy.toString("yyyy-MM-dd")));

            // when
            final LocalDate fiveDaysFromNow = Clock.getTimeAsLocalDate().plusDays(5);
            unwrap(toDoItem).setDueBy(fiveDaysFromNow);

            // then
            assertThat(container().titleOf(toDoItem), containsString("due by " + fiveDaysFromNow.toString("yyyy-MM-dd")));
        }
View Full Code Here

            @Test
            public void happyCase() throws Exception {

                // given
                final LocalDate todaysDate = clockService.now();
                toDoItem.setDueBy(todaysDate);
                toDoItem.updateCost(new BigDecimal("123.45"));

                duplicateToDoItem = toDoItem.duplicate(
                        unwrap(toDoItem).default0Duplicate(),
View Full Code Here

                            statement.setObject(i, value, java.sql.Types.DATE);
                        } catch (final SQLException e) {
                            // TODO This daft catch is required my MySQL, which
                            // also requires the TimeZone offset to be
                            // "undone"
                            final LocalDate localDate = (LocalDate) value;
                            final int millisOffset = -DateTimeZone.getDefault().getOffset(null);
                            final java.util.Date javaDate =
                                localDate.toDateTimeAtStartOfDay(DateTimeZone.forOffsetMillis(millisOffset)).toDate();

                            statement.setObject(i, javaDate, java.sql.Types.DATE);
                        }
                    } else if (value instanceof InputStream) {
                        statement.setBlob(i, (InputStream) value);
View Full Code Here

   
    private LocalDate someLocalDate;
   
    @Before
    public void setUp() throws Exception {
        someLocalDate = new LocalDate(2012,4,1);
       
        strSetting = new SettingAbstractForTesting("strSetting", "ABC", SettingType.STRING);
        intSetting = new SettingAbstractForTesting("intSetting", "" + Integer.MAX_VALUE, SettingType.INT);
        localDateSetting = new SettingAbstractForTesting("localDateSetting", someLocalDate.toString(SettingAbstract.DATE_FORMATTER), SettingType.LOCAL_DATE);
        longSetting = new SettingAbstractForTesting("longSetting", ""+Long.MAX_VALUE, SettingType.LONG);
View Full Code Here

            @Test
            public void happyCase() throws Exception {

                // when
                final LocalDate fiveDaysFromNow = clockService.now().plusDays(5);
                toDoItem.setDueBy(fiveDaysFromNow);

                // then
                assertThat(toDoItem.getDueBy(), is(fiveDaysFromNow));
            }
View Full Code Here

            }

            @Test
            public void canBeUpToSixDaysInPast() throws Exception {

                final LocalDate nowAsLocalDate = clockService.now();
                final LocalDate sixDaysAgo = nowAsLocalDate.plusDays(-5);

                // when
                toDoItem.setDueBy(sixDaysAgo);

                // then
View Full Code Here


            @Test
            public void cannotBeMoreThanSixDaysInPast() throws Exception {

                final LocalDate sevenDaysAgo = Clock.getTimeAsLocalDate().plusDays(-7);

                // when, then
                expectedExceptions.expectMessage("Due by date cannot be more than one week old");
                toDoItem.setDueBy(sevenDaysAgo);
            }
View Full Code Here

    protected Object preparedStatementObject(final ObjectAdapter value) {
        final Object o = value.getObject();
        if (o instanceof java.sql.Date) {
            final java.sql.Date javaSqlDate = (java.sql.Date) value.getObject();
            final long millisSinceEpoch = javaSqlDate.getTime();
            return new LocalDate(millisSinceEpoch);
        } else if (o instanceof Date) {
            final Date asDate = (Date) value.getObject();
            return new LocalDate(asDate.getMillisSinceEpoch());
        } else {
            throw new IsisApplicationException("Unimplemented JdbcDateMapper instance type: "
                + value.getClass().toString());
        }
    }
View Full Code Here

TOP

Related Classes of org.joda.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.