Class EpochDateTransformer
java.lang.Object
com.invirgance.convirgance.transform.date.EpochDateTransformer
- All Implemented Interfaces:
IdentityTransformer,Transformer
Transforms long numbers representing a millisecond timestamp into Date objects.
This transformer transforms Epoch millisecond timestamps into their
corresponding Date following the format of Date.getTime() in
both Java and JavaScript.
Example usage:
Iterable<JSONObject> stream = ...;
// Convert specified fields
EpochDateTransformer transformer = new EpochDateTransformer("created_at", "updated_at");
// Apply the transformation
stream = transformer.transform(stream);
- Author:
- jbanes
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPrepares a new EpochDateTransformer for transforming epoch values to Dates.EpochDateTransformer(String... columns) Creates a new EpochDateTransformer for transforming the epoch values of a JSONObject to Dates. -
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
-
EpochDateTransformer
public EpochDateTransformer()Prepares a new EpochDateTransformer for transforming epoch values to Dates. Note thatsetColumns(java.lang.String...)must be called or the transformation will throw an exception when invoked. -
EpochDateTransformer
Creates a new EpochDateTransformer for transforming the epoch values of a JSONObject to Dates.- 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.
-