Class ISOStringDateTransformer
java.lang.Object
com.invirgance.convirgance.transform.date.ISOStringDateTransformer
- All Implemented Interfaces:
IdentityTransformer,Transformer
Transforms ISO 8601 formatted strings into Date objects.
Example usage:
Iterable<JSONObject> stream = ...;
// Convert specified fields
StringDateTransformer transformer = new StringDateTransformer("created_at", "updated_at");
// Apply the transformation
stream = transformer.transform(stream);
- Author:
- jbanes
-
Constructor Summary
ConstructorsConstructorDescriptionPrepares a new transformer to parse ISO 8601 strings into Date objects.ISOStringDateTransformer(String... columns) Creates a new transformer that parses ISO 8601 strings into Date objects -
Method Summary
Modifier and TypeMethodDescriptionString[]Get the list of columns that will be transformed.voidsetColumns(String... columns) Set the list of columns to transform.transform(JSONObject record) Transforms the provided record in some way.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.invirgance.convirgance.transform.IdentityTransformer
transformMethods inherited from interface com.invirgance.convirgance.transform.Transformer
transform
-
Constructor Details
-
ISOStringDateTransformer
public ISOStringDateTransformer()Prepares a new transformer to parse ISO 8601 strings into Date objects. You must callsetColumns(java.lang.String...)before attempting a transform or an exception will be thrown. -
ISOStringDateTransformer
Creates a new transformer that parses ISO 8601 strings into Date objects- Parameters:
columns- field names to include in the conversion
-
-
Method Details
-
getColumns
Get the list of columns that will be transformed. Null is returned if no column list has been set. In this case, all columns will be checked.- Returns:
- list of columns to be converted or null if all columns will be checked
-
setColumns
Set the list of columns to transform. Null may be passed if all columns should be checked and transformed if they are of typeDate.- Parameters:
columns- list of columns to be converted
-
transform
Description copied from interface:IdentityTransformerTransforms the provided record in some way.- Specified by:
transformin interfaceIdentityTransformer- Parameters:
record- The JSONObject to transform/modify.- Returns:
- The modified JSONObject.
- Throws:
ConvirganceException- If an error occurs while making transformations.
-