Package org.joda.time

Examples of org.joda.time.LocalDateTime


                    persistentAuditEvents = persistenceAuditEventRepository.findAll();
                } else if (after == null) {
                    persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
                } else {
                    persistentAuditEvents =
                            persistenceAuditEventRepository.findByPrincipalAndAuditEventDateGreaterThan(principal, new LocalDateTime(after));
                }

                return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
            }

            @Override
            public void add(AuditEvent event) {
                PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
                persistentAuditEvent.setPrincipal(event.getPrincipal());
                persistentAuditEvent.setAuditEventType(event.getType());
                persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
                persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));

                persistenceAuditEventRepository.save(persistentAuditEvent);
            }
        };
View Full Code Here


     *
     * @return DateTime formatted string
     */
    public String getAsText() {
        Date value = (Date) getValue();
        return value != null ? new LocalDateTime(value).toString(formatter) : "";
    }
View Full Code Here

    public void setAsText( String text ) throws IllegalArgumentException {
        if ( allowEmpty && !StringUtils.hasText(text) ) {
            // Treat empty String as null value.
            setValue(null);
        } else {
            setValue(new LocalDateTime(formatter.parseDateTime(text)));
        }
    }
View Full Code Here

  @Test
  public void writesAndReadsDates() {
    Date created = new Date();
    Calendar modified = Calendar.getInstance();
    LocalDateTime deleted = LocalDateTime.now();
    DateEntity entity = new DateEntity(created, modified, deleted);

    CouchbaseDocument converted = new CouchbaseDocument();
    converter.write(entity, converted);
    assertEquals(created.getTime(), converted.getPayload().get("created"));
    assertEquals(modified.getTimeInMillis() / 1000, converted.getPayload().get("modified"));
    assertEquals(deleted.toDate().getTime(), converted.getPayload().get("deleted"));

    DateEntity read = converter.read(DateEntity.class, converted);
    assertEquals(created.getTime(), read.created.getTime());
    assertEquals(modified.getTimeInMillis() / 1000, read.modified.getTimeInMillis() / 1000);
    assertEquals(deleted.toDate().getTime(), read.deleted.toDate().getTime());
  }
View Full Code Here

        final LinkRepresentation updateLink = domainObjectRepr.getLinkWithRel(Rel.UPDATE);
       
        final JsonRepresentation argRepr = updateLink.getArguments();
       
        final LocalDate ld = new LocalDate(2013,5,1);
        final LocalDateTime ldt = new LocalDateTime(2013,2,1,14,15,0);
        final DateTime dt = new DateTime(2013,2,1,14,15,0);
        final String s = "New string";
       
        argRepr.mapPut("localDateProperty.value", asIsoNoT(ld.toDate()));
        argRepr.mapPut("localDateTimeProperty.value", asIso(ldt.toDate()));
        argRepr.mapPut("dateTimeProperty.value", asIso(dt.toDate()));
        argRepr.mapPut("stringProperty.value", s);

        final RestfulResponse<JsonRepresentation> result = client.follow(updateLink, argRepr);
        assertThat(result.getStatus(), is(HttpStatusCode.OK));
       
        final DomainObjectRepresentation afterResp = result.getEntity().as(DomainObjectRepresentation.class);
       
        assertThat(afterResp.getProperty("localDateProperty").getDate("value"), is(ld.toDate()));
        assertThat(afterResp.getProperty("localDateTimeProperty").getDateTime("value"), is(ldt.toDate()));
        assertThat(afterResp.getProperty("dateTimeProperty").getDateTime("value"), is(dt.toDate()));
        assertThat(afterResp.getProperty("stringProperty").getString("value"), is(s));
    }
View Full Code Here

        argRepr = modifyLink.getArguments().mapPut("value", asIsoNoT(ld.toDate()));
        assertThat(followedRepr(modifyLink,argRepr).getDate("value"), is(ld.toDate()));


        // LocalDateTime
        final LocalDateTime ldt = new LocalDateTime(2013,2,1,14,15,0);
        modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "localDateTimeProperty");
        argRepr = modifyLink.getArguments().mapPut("value", asIso(ldt.toDate()));
        assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(ldt.toDate()));
       
        // DateTime
        final DateTime dt = new DateTime(2013,2,1,14,15,0);
        modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "dateTimeProperty");
        argRepr = modifyLink.getArguments().mapPut("value", asIso(dt.toDate()));
View Full Code Here

    @Test
    public void testNormalUserNoPackageOneCall() {
        Map<UserField, Object> data = new HashMap<UserField, Object>();
        data.put(UserField.kUserType, UserType.kNormal);
        List<Slip> slips = new ArrayList<Slip>();
        slips.add(new Slip(SlipType.kPhoneCall, new LocalDateTime(), 1));
        data.put(UserField.kSlips, slips);
        UserMonthUsage usage = new UserMonthUsage(2, data);
        assertEquals(Money.get(0, 60), calculator.calculate(usage));
    }
View Full Code Here

    @Test
    public void testNormalUserNoPackageOneShortMessage() {
        Map<UserField, Object> data = new HashMap<UserField, Object>();
        data.put(UserField.kUserType, UserType.kNormal);
        List<Slip> slips = new ArrayList<Slip>();
        slips.add(new Slip(SlipType.kShortMessage, new LocalDateTime(), 1));
        data.put(UserField.kSlips, slips);
        UserMonthUsage usage = new UserMonthUsage(3, data);
        assertEquals(Money.get(0, 10), calculator.calculate(usage));
    }
View Full Code Here

    @Test
    public void testNormalUserNoPackage100kData() {
        Map<UserField, Object> data = new HashMap<UserField, Object>();
        data.put(UserField.kUserType, UserType.kNormal);
        List<Slip> slips = new ArrayList<Slip>();
        slips.add(new Slip(SlipType.kInternet, new LocalDateTime(), 100));
        data.put(UserField.kSlips, slips);
        UserMonthUsage usage = new UserMonthUsage(4, data);
        assertEquals(Money.get(0, 50), calculator.calculate(usage));
    }
View Full Code Here

    public void testNormalUserPhoneCallPackageNoActivity() {
        Map<UserField, Object> data = new HashMap<UserField, Object>();
        data.put(UserField.kUserType, UserType.kNormal);

        List<Slip> slips = new ArrayList<Slip>();
        slips.add(new Slip(SlipType.kPhoneCall, new LocalDateTime(), 0));
        data.put(UserField.kSlips, slips);

        data.put(UserField.kPackages, getPackages(PackageType.kNormalUserPhoneCall));

        UserMonthUsage usage = new UserMonthUsage(5, data);
View Full Code Here

TOP

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