![JAR search and dependency download from the Maven repository](/logo.png)
com.mongodb.spark.pickle.CalendarTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongo-hadoop-spark Show documentation
Show all versions of mongo-hadoop-spark Show documentation
The MongoDB Connector for Hadoop is a plugin for Hadoop that provides the ability to use MongoDB as an input source and/or an output destination.
package com.mongodb.spark.pickle;
import org.bson.Transformer;
import java.util.Calendar;
import java.util.TimeZone;
/**
* Transformer that turns java.util.Calendar objects into java.util.Date
* objects.
*
* This class is needed because Spark constructs pickled Python
* datetime.datetime objects into java.util.GregorianCalendar instances instead
* of java.util.Date objects.
*/
public class CalendarTransformer implements Transformer {
@Override
public Object transform(final Object objectToTransform) {
Calendar calendar = (Calendar) objectToTransform;
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
return calendar.getTime();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy