Example usage for org.joda.time.format ISODateTimeFormat dateTime

List of usage examples for org.joda.time.format ISODateTimeFormat dateTime

Introduction

In this page you can find the example usage for org.joda.time.format ISODateTimeFormat dateTime.

Prototype

public static DateTimeFormatter dateTime() 

Source Link

Document

Returns a formatter that combines a full date and time, separated by a 'T' (yyyy-MM-dd'T'HH:mm:ss.SSSZZ).

Usage

From source file:ar.com.wolox.commons.base.json.DateTimeJsonDeserializer.java

License:Apache License

@Override
public DateTime deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException {
    final String isoDateTime = jp.readValueAs(String.class);
    return ISODateTimeFormat.dateTime().parseDateTime(isoDateTime);
}

From source file:ar.com.wolox.commons.base.json.DateTimeJsonSerializer.java

License:Apache License

@Override
public void serialize(final DateTime value, final JsonGenerator jgen, final SerializerProvider provider)
        throws IOException {
    jgen.writeObject(ISODateTimeFormat.dateTime().print(value));
}

From source file:ar.com.wolox.commons.base.json.JSONSerializableDateTime.java

License:Apache License

/**
 * Creates a {@link JSONSerializableDateTime} from a {@link DateTime}
 *
 * @param date//  w ww .  j  ava 2 s.  c  o  m
 * @return
 */
public static JSONSerializableDateTime create(@NotNull final DateTime date) {
    if (date == null) {
        throw new IllegalArgumentException("The date to be serialized cannot be null");
    }

    final JSONSerializableDateTime serialized = new JSONSerializableDateTime();
    serialized.setIsoDate(ISODateTimeFormat.dateTime().print(date));
    serialized.setTimeZone(date.getChronology().getZone().getID());
    return serialized;
}

From source file:ar.com.wolox.commons.base.json.JSONSerializableDateTime.java

License:Apache License

/**
 * @return The deserialized date time
 */
public DateTime toDateTime() {
    return ISODateTimeFormat.dateTime().withZone(DateTimeZone.forID(timeZone)).parseDateTime(isoDate);
}

From source file:be.e_contract.dssp.client.PendingRequestFactory.java

License:Open Source License

/**
 * Creates the base64 encoded dss:PendingRequest element to be used for the
 * Browser POST phase./*from ww  w  .  j av  a2 s  .c om*/
 * 
 * <p>
 * The content of the parameter {@code authorizedSubjects} can be
 * constructed as follows. The {@code authorizedSubjects} parameter is a set
 * of regular expressions. Suppose you have a national registration number
 * that is allowed to sign, then you can construct the
 * {@code authorizedSubjects} as follows.
 * </p>
 * 
 * <pre>
 * Set&lt;String&gt; authorizedSubjects = new HashSet&lt;String&gt;();
 * String nrn = &quot;1234&quot;;
 * X500Principal x500Principal = new X500Principal(&quot;SERIALNUMBER=&quot; + nrn);
 * String authorizedSubject = x500Principal.getName() + &quot;,.*,C=BE&quot;;
 * authorizedSubjects.add(authorizedSubject);
 * </pre>
 * 
 * @param session
 *            the session object.
 * @param destination
 *            the destination URL within your web application. This is where
 *            the DSS will return to.
 * @param language
 *            the optional language
 * @param visibleSignatureConfiguration
 *            the optional visible signature configuration.
 * @param returnSignerIdentity
 *            indicates whether the DSS should return the signatory's
 *            identity.
 * @param authorizedSubjects
 *            the optional signatory subject DNs that are authorized to
 *            sign. An authorized subject can be an regular expression.
 * @return
 * @see VisibleSignatureConfiguration
 */
public static String createPendingRequest(DigitalSignatureServiceSession session, String destination,
        String language, VisibleSignatureConfiguration visibleSignatureConfiguration,
        boolean returnSignerIdentity, Set<String> authorizedSubjects) {
    ObjectFactory asyncObjectFactory = new ObjectFactory();
    be.e_contract.dssp.ws.jaxb.dss.ObjectFactory dssObjectFactory = new be.e_contract.dssp.ws.jaxb.dss.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.wsa.ObjectFactory wsaObjectFactory = new be.e_contract.dssp.ws.jaxb.wsa.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.wsu.ObjectFactory wsuObjectFactory = new be.e_contract.dssp.ws.jaxb.wsu.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.dss.vs.ObjectFactory vsObjectFactory = new be.e_contract.dssp.ws.jaxb.dss.vs.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.xacml.policy.ObjectFactory xacmlObjectFactory = new be.e_contract.dssp.ws.jaxb.xacml.policy.ObjectFactory();

    PendingRequest pendingRequest = asyncObjectFactory.createPendingRequest();
    pendingRequest.setProfile(DigitalSignatureServiceConstants.PROFILE);
    AnyType optionalInputs = dssObjectFactory.createAnyType();
    pendingRequest.setOptionalInputs(optionalInputs);

    optionalInputs.getAny()
            .add(dssObjectFactory.createAdditionalProfile(DigitalSignatureServiceConstants.DSS_ASYNC_PROFILE));
    optionalInputs.getAny().add(asyncObjectFactory.createResponseID(session.getResponseId()));

    if (null != language) {
        optionalInputs.getAny().add(dssObjectFactory.createLanguage(language));
    }

    if (returnSignerIdentity) {
        optionalInputs.getAny().add(dssObjectFactory.createReturnSignerIdentity(null));
    }

    AttributedURIType messageId = wsaObjectFactory.createAttributedURIType();
    optionalInputs.getAny().add(wsaObjectFactory.createMessageID(messageId));
    String requestId = "uuid:" + UUID.randomUUID().toString();
    messageId.setValue(requestId);
    session.setInResponseTo(requestId);

    TimestampType timestamp = wsuObjectFactory.createTimestampType();
    optionalInputs.getAny().add(wsuObjectFactory.createTimestamp(timestamp));
    AttributedDateTime created = wsuObjectFactory.createAttributedDateTime();
    timestamp.setCreated(created);
    DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime()
            .withChronology(ISOChronology.getInstanceUTC());
    DateTime createdDateTime = new DateTime();
    created.setValue(dateTimeFormatter.print(createdDateTime));
    AttributedDateTime expires = wsuObjectFactory.createAttributedDateTime();
    timestamp.setExpires(expires);
    DateTime expiresDateTime = createdDateTime.plusMinutes(5);
    expires.setValue(dateTimeFormatter.print(expiresDateTime));

    EndpointReferenceType replyTo = wsaObjectFactory.createEndpointReferenceType();
    optionalInputs.getAny().add(wsaObjectFactory.createReplyTo(replyTo));
    AttributedURIType address = wsaObjectFactory.createAttributedURIType();
    replyTo.setAddress(address);
    address.setValue(destination);
    session.setDestination(destination);

    if (null != visibleSignatureConfiguration) {
        VisibleSignatureConfigurationType visSigConfig = vsObjectFactory
                .createVisibleSignatureConfigurationType();
        optionalInputs.getAny().add(vsObjectFactory.createVisibleSignatureConfiguration(visSigConfig));
        VisibleSignaturePolicyType visibleSignaturePolicy = VisibleSignaturePolicyType.DOCUMENT_SUBMISSION_POLICY;
        visSigConfig.setVisibleSignaturePolicy(visibleSignaturePolicy);
        VisibleSignatureItemsConfigurationType visibleSignatureItemsConfiguration = vsObjectFactory
                .createVisibleSignatureItemsConfigurationType();
        visSigConfig.setVisibleSignatureItemsConfiguration(visibleSignatureItemsConfiguration);
        if (visibleSignatureConfiguration.getLocation() != null) {
            VisibleSignatureItemType locationVisibleSignatureItem = vsObjectFactory
                    .createVisibleSignatureItemType();
            visibleSignatureItemsConfiguration.getVisibleSignatureItem().add(locationVisibleSignatureItem);
            locationVisibleSignatureItem.setItemName(ItemNameEnum.SIGNATURE_PRODUCTION_PLACE);
            ItemValueStringType itemValue = vsObjectFactory.createItemValueStringType();
            locationVisibleSignatureItem.setItemValue(itemValue);
            itemValue.setItemValue(visibleSignatureConfiguration.getLocation());
        }
        if (visibleSignatureConfiguration.getRole() != null) {
            VisibleSignatureItemType locationVisibleSignatureItem = vsObjectFactory
                    .createVisibleSignatureItemType();
            visibleSignatureItemsConfiguration.getVisibleSignatureItem().add(locationVisibleSignatureItem);
            locationVisibleSignatureItem.setItemName(ItemNameEnum.SIGNATURE_REASON);
            ItemValueStringType itemValue = vsObjectFactory.createItemValueStringType();
            locationVisibleSignatureItem.setItemValue(itemValue);
            itemValue.setItemValue(visibleSignatureConfiguration.getRole());
        }
        if (visibleSignatureConfiguration.getSignerImageUri() != null) {
            PixelVisibleSignaturePositionType visibleSignaturePosition = vsObjectFactory
                    .createPixelVisibleSignaturePositionType();
            visSigConfig.setVisibleSignaturePosition(visibleSignaturePosition);
            visibleSignaturePosition.setPageNumber(BigInteger.valueOf(visibleSignatureConfiguration.getPage()));
            visibleSignaturePosition.setX(BigInteger.valueOf(visibleSignatureConfiguration.getX()));
            visibleSignaturePosition.setY(BigInteger.valueOf(visibleSignatureConfiguration.getY()));

            VisibleSignatureItemType visibleSignatureItem = vsObjectFactory.createVisibleSignatureItemType();
            visibleSignatureItemsConfiguration.getVisibleSignatureItem().add(visibleSignatureItem);
            visibleSignatureItem.setItemName(ItemNameEnum.SIGNER_IMAGE);
            ItemValueURIType itemValue = vsObjectFactory.createItemValueURIType();
            itemValue.setItemValue(visibleSignatureConfiguration.getSignerImageUri());
            visibleSignatureItem.setItemValue(itemValue);
        }
        if (visibleSignatureConfiguration.getCustomText() != null) {
            VisibleSignatureItemType customTextVisibleSignatureItem = vsObjectFactory
                    .createVisibleSignatureItemType();
            visibleSignatureItemsConfiguration.getVisibleSignatureItem().add(customTextVisibleSignatureItem);
            customTextVisibleSignatureItem.setItemName(ItemNameEnum.CUSTOM_TEXT);
            ItemValueStringType itemValue = vsObjectFactory.createItemValueStringType();
            customTextVisibleSignatureItem.setItemValue(itemValue);
            itemValue.setItemValue(visibleSignatureConfiguration.getCustomText());
        }
    }

    if (null != authorizedSubjects) {
        PolicyType policy = xacmlObjectFactory.createPolicyType();
        optionalInputs.getAny().add(xacmlObjectFactory.createPolicy(policy));
        policy.setPolicyId("urn:" + UUID.randomUUID().toString());
        policy.setRuleCombiningAlgId("urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:deny-overrides");
        TargetType target = xacmlObjectFactory.createTargetType();
        policy.setTarget(target);
        RuleType rule = xacmlObjectFactory.createRuleType();
        policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(rule);
        rule.setRuleId("whatever");
        rule.setEffect(EffectType.PERMIT);
        TargetType ruleTarget = xacmlObjectFactory.createTargetType();
        rule.setTarget(ruleTarget);
        SubjectsType subjects = xacmlObjectFactory.createSubjectsType();
        ruleTarget.setSubjects(subjects);
        for (String authorizedSubject : authorizedSubjects) {
            SubjectType subject = xacmlObjectFactory.createSubjectType();
            subjects.getSubject().add(subject);
            SubjectMatchType subjectMatch = xacmlObjectFactory.createSubjectMatchType();
            subject.getSubjectMatch().add(subjectMatch);
            subjectMatch.setMatchId("urn:oasis:names:tc:xacml:2.0:function:x500Name-regexp-match");
            AttributeValueType attributeValue = xacmlObjectFactory.createAttributeValueType();
            subjectMatch.setAttributeValue(attributeValue);
            attributeValue.setDataType("http://www.w3.org/2001/XMLSchema#string");
            attributeValue.getContent().add(authorizedSubject);
            SubjectAttributeDesignatorType subjectAttributeDesigator = xacmlObjectFactory
                    .createSubjectAttributeDesignatorType();
            subjectMatch.setSubjectAttributeDesignator(subjectAttributeDesigator);
            subjectAttributeDesigator.setAttributeId("urn:oasis:names:tc:xacml:1.0:subject:subject-id");
            subjectAttributeDesigator.setDataType("urn:oasis:names:tc:xacml:1.0:data-type:x500Name");
        }
        ResourcesType resources = xacmlObjectFactory.createResourcesType();
        ruleTarget.setResources(resources);
        ResourceType resource = xacmlObjectFactory.createResourceType();
        resources.getResource().add(resource);
        ResourceMatchType resourceMatch = xacmlObjectFactory.createResourceMatchType();
        resource.getResourceMatch().add(resourceMatch);
        resourceMatch.setMatchId("urn:oasis:names:tc:xacml:1.0:function:anyURI-equal");
        AttributeValueType resourceAttributeValue = xacmlObjectFactory.createAttributeValueType();
        resourceMatch.setAttributeValue(resourceAttributeValue);
        resourceAttributeValue.setDataType("http://www.w3.org/2001/XMLSchema#anyURI");
        resourceAttributeValue.getContent().add("urn:be:e-contract:dss");
        AttributeDesignatorType resourceAttributeDesignator = xacmlObjectFactory
                .createAttributeDesignatorType();
        resourceMatch.setResourceAttributeDesignator(resourceAttributeDesignator);
        resourceAttributeDesignator.setAttributeId("urn:oasis:names:tc:xacml:1.0:resource:resource-id");
        resourceAttributeDesignator.setDataType("http://www.w3.org/2001/XMLSchema#anyURI");

        ActionsType actions = xacmlObjectFactory.createActionsType();
        ruleTarget.setActions(actions);
        ActionType action = xacmlObjectFactory.createActionType();
        actions.getAction().add(action);
        ActionMatchType actionMatch = xacmlObjectFactory.createActionMatchType();
        action.getActionMatch().add(actionMatch);
        actionMatch.setMatchId("urn:oasis:names:tc:xacml:1.0:function:string-equal");
        AttributeValueType actionAttributeValue = xacmlObjectFactory.createAttributeValueType();
        actionMatch.setAttributeValue(actionAttributeValue);
        actionAttributeValue.setDataType("http://www.w3.org/2001/XMLSchema#string");
        actionAttributeValue.getContent().add("sign");
        AttributeDesignatorType actionAttributeDesignator = xacmlObjectFactory.createAttributeDesignatorType();
        actionMatch.setActionAttributeDesignator(actionAttributeDesignator);
        actionAttributeDesignator.setAttributeId("urn:oasis:names:tc:xacml:1.0:action:action-id");
        actionAttributeDesignator.setDataType("http://www.w3.org/2001/XMLSchema#string");
    }

    // marshall to DOM
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("DOM error: " + e.getMessage(), e);
    }
    Document document = documentBuilder.newDocument();

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class,
                be.e_contract.dssp.ws.jaxb.wsa.ObjectFactory.class,
                be.e_contract.dssp.ws.jaxb.wsu.ObjectFactory.class,
                be.e_contract.dssp.ws.jaxb.dss.vs.ObjectFactory.class,
                be.e_contract.dssp.ws.jaxb.xacml.policy.ObjectFactory.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.marshal(pendingRequest, document);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }

    try {
        sign(document, session);
    } catch (Exception e) {
        throw new RuntimeException("error signing: " + e.getMessage(), e);
    }

    // marshall to base64 encoded
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer;
    try {
        transformer = transformerFactory.newTransformer();
    } catch (TransformerConfigurationException e) {
        throw new RuntimeException("JAXP config error: " + e.getMessage(), e);
    }
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        transformer.transform(new DOMSource(document), new StreamResult(outputStream));
    } catch (TransformerException e) {
        throw new RuntimeException("JAXP error: " + e.getMessage(), e);
    }
    String encodedPendingRequest = Base64.encode(outputStream.toByteArray());
    return encodedPendingRequest;
}

From source file:cc.vidr.datum.term.DateTimeTerm.java

License:Open Source License

public String toString() {
    return toString(ISODateTimeFormat.dateTime());
}

From source file:ch.windmobile.server.social.mongodb.ChatServiceImpl.java

License:Open Source License

@Override
public Messages findMessages(String chatRoomId, int maxCount) {
    if (maxCount <= 0) {
        throw new IllegalArgumentException("maxCount arg[1] must be greater than 0");
    }/*from  w w w  . j a  v  a  2  s .  c o  m*/
    final String collectionName = computeCollectionName(chatRoomId);

    final DBObject fields = BasicDBObjectBuilder.start("_id", 1).add(MongoDBConstants.CHAT_PROP_USER, 1)
            .add(MongoDBConstants.CHAT_PROP_TEXT, 1).add(MongoDBConstants.CHAT_PROP_TIME, 1)
            .add(MongoDBConstants.CHAT_PROP_EMAIL_HASH, 1).get();
    DBCursor result = db.getCollection(collectionName).find(null, fields)
            .sort(new BasicDBObject("$natural", -1)).limit(maxCount);
    List<DBObject> all = result.toArray();

    Messages messages = new Messages();
    for (DBObject dbObject : all) {
        Message message = new Message();
        message.setId(dbObject.get("_id").toString());
        DateTime dateTime = ISODateTimeFormat.dateTime().parseDateTime((String) dbObject.get("time"));
        message.setDate(dateTime);
        message.setPseudo((String) dbObject.get(MongoDBConstants.CHAT_PROP_USER));
        message.setText((String) dbObject.get(MongoDBConstants.CHAT_PROP_TEXT));
        message.setEmailHash((String) dbObject.get(MongoDBConstants.CHAT_PROP_EMAIL_HASH));

        messages.getMessages().add(message);
    }
    return messages;
}

From source file:com.allogy.json.jackson.joda.ISODateTimeDeserializer.java

License:Apache License

public ISODateTimeDeserializer() {
    dateTimeFormatter = ISODateTimeFormat.dateTime().withOffsetParsed();
}

From source file:com.allogy.json.jackson.joda.ISODateTimeSerializer.java

License:Apache License

public ISODateTimeSerializer() {
    dateTimeFormatter = ISODateTimeFormat.dateTime();
}

From source file:com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBReflectorUtil.java

License:Apache License

/**
 * Note this method is synchronized on {@link #argumentMarshallerCache} while being executed.
 *//*www .j  a  v a 2  s  . co  m*/
private ArgumentMarshaller computeArgumentMarshaller(final Method getter) {
    ArgumentMarshaller marshaller;
    Class<?> returnType = getter.getReturnType();
    if (Set.class.isAssignableFrom(returnType)) {
        final Type genericType = getter.getGenericReturnType();
        if (genericType instanceof ParameterizedType) {
            if (((ParameterizedType) genericType).getActualTypeArguments()[0].toString().equals("byte[]")) {
                returnType = byte[].class;
            } else {
                returnType = (Class<?>) ((ParameterizedType) genericType).getActualTypeArguments()[0];
            }
        }

        if (Date.class.isAssignableFrom(returnType)) {
            marshaller = new StringSetAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<String> timestamps = new LinkedList<String>();
                    for (final Object o : (Set<?>) obj) {
                        timestamps.add(DateUtils.formatISO8601Date((Date) o));
                    }
                    return new AttributeValue().withSS(timestamps);
                }
            };
        } else if (Calendar.class.isAssignableFrom(returnType)) {
            marshaller = new StringSetAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<String> timestamps = new LinkedList<String>();
                    for (final Object o : (Set<?>) obj) {
                        timestamps.add(DateUtils.formatISO8601Date(((Calendar) o).getTime()));
                    }
                    return new AttributeValue().withSS(timestamps);
                }
            };
        } else if (DateTime.class.isAssignableFrom(returnType)) {
            marshaller = new StringSetAttributeMarshaller() {

                private final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<String> timestamps = new LinkedList<String>();
                    for (final Object o : (Set<?>) obj) {
                        timestamps.add(dateTimeFormatter.print((DateTime) o));
                    }
                    return new AttributeValue().withSS(timestamps);
                }
            };
        } else if (boolean.class.isAssignableFrom(returnType) || Boolean.class.isAssignableFrom(returnType)) {
            marshaller = new NumberSetAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<String> booleanAttributes = new ArrayList<String>();
                    for (final Object b : (Set<?>) obj) {
                        if (b == null || !(Boolean) b) {
                            booleanAttributes.add("0");
                        } else {
                            booleanAttributes.add("1");
                        }
                    }
                    return new AttributeValue().withNS(booleanAttributes);
                }
            };
        } else if (returnType.isPrimitive() || Number.class.isAssignableFrom(returnType)) {
            marshaller = new NumberSetAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<String> attributes = new ArrayList<String>();
                    for (final Object o : (Set<?>) obj) {
                        attributes.add(String.valueOf(o));
                    }
                    return new AttributeValue().withNS(attributes);
                }
            };
        } else if (ByteBuffer.class.isAssignableFrom(returnType)) {
            marshaller = new BinarySetAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                    for (final Object o : (Set<?>) obj) {
                        attributes.add((ByteBuffer) o);
                    }
                    return new AttributeValue().withBS(attributes);
                }
            };
        } else if (byte[].class.isAssignableFrom(returnType)) {
            marshaller = new BinarySetAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    final List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                    for (final Object o : (Set<?>) obj) {
                        attributes.add(ByteBuffer.wrap((byte[]) o));
                    }
                    return new AttributeValue().withBS(attributes);
                }
            };
        } else {
            // subclass may extend the behavior by overriding the
            // defaultCollectionArgumentMarshaller method
            marshaller = defaultCollectionArgumentMarshaller(returnType);
        }
    } else if (Collection.class.isAssignableFrom(returnType)) {
        throw new DynamoDBMappingException("Non-set collections aren't supported: "
                + (getter.getDeclaringClass() + "." + getter.getName()));
    } else { // Non-set return type
        if (Date.class.isAssignableFrom(returnType)) {
            marshaller = new StringAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    return new AttributeValue().withS(DateUtils.formatISO8601Date((Date) obj));
                }
            };
        } else if (Calendar.class.isAssignableFrom(returnType)) {
            marshaller = new StringAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    return new AttributeValue().withS(DateUtils.formatISO8601Date(((Calendar) obj).getTime()));
                }
            };
        } else if (DateTime.class.isAssignableFrom(returnType)) {
            marshaller = new StringAttributeMarshaller() {

                private final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();

                @Override
                public AttributeValue marshall(final Object obj) {
                    return new AttributeValue().withS(dateTimeFormatter.print((DateTime) obj));
                }
            };
        } else if (boolean.class.isAssignableFrom(returnType) || Boolean.class.isAssignableFrom(returnType)) {
            marshaller = new NumberAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    if (obj == null || !(Boolean) obj) {
                        return new AttributeValue().withN("0");
                    } else {
                        return new AttributeValue().withN("1");
                    }
                }
            };
        } else if (returnType.isPrimitive() || Number.class.isAssignableFrom(returnType)) {
            marshaller = new NumberAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    return new AttributeValue().withN(String.valueOf(obj));
                }
            };
        } else if (returnType == String.class) {
            marshaller = new StringAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    if (((String) obj).length() == 0) {
                        return null;
                    }
                    return new AttributeValue().withS(String.valueOf(obj));
                }
            };
        } else if (returnType == ByteBuffer.class) {
            marshaller = new BinaryAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    return new AttributeValue().withB((ByteBuffer) obj);
                }
            };
        } else if (returnType == byte[].class) {
            marshaller = new BinaryAttributeMarshaller() {

                @Override
                public AttributeValue marshall(final Object obj) {
                    return new AttributeValue().withB(ByteBuffer.wrap((byte[]) obj));
                }
            };
        } else {
            marshaller = defaultArgumentMarshaller(returnType, getter);
        }
    }
    return marshaller;
}