Commit abf35d62 by Shwetha GS

using UTC time formatter for type serialisation

parent e4d54817
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
package org.apache.hadoop.metadata.typesystem.json package org.apache.hadoop.metadata.typesystem.json
import java.text.SimpleDateFormat
import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableList
import org.apache.hadoop.metadata.typesystem.TypesDef import org.apache.hadoop.metadata.typesystem.TypesDef
import org.apache.hadoop.metadata.typesystem.types.DataTypes.{ArrayType, MapType, TypeCategory} import org.apache.hadoop.metadata.typesystem.types.DataTypes.{ArrayType, MapType, TypeCategory}
...@@ -85,8 +87,13 @@ object TypesSerialization { ...@@ -85,8 +87,13 @@ object TypesSerialization {
toJson(ts, typNames.toIndexedSeq: _*) toJson(ts, typNames.toIndexedSeq: _*)
} }
val _formats = new DefaultFormats {
override val dateFormatter = TypeSystem.getInstance().getDateFormat.asInstanceOf[SimpleDateFormat]
override val typeHints = NoTypeHints
}
def toJson(ts: TypeSystem, export: IDataType[_] => Boolean): String = { def toJson(ts: TypeSystem, export: IDataType[_] => Boolean): String = {
implicit val formats = org.json4s.native.Serialization.formats(NoTypeHints) + new MultiplicitySerializer implicit val formats = _formats + new MultiplicitySerializer
val typsDef = convertToTypesDef(ts, export) val typsDef = convertToTypesDef(ts, export)
...@@ -94,13 +101,13 @@ object TypesSerialization { ...@@ -94,13 +101,13 @@ object TypesSerialization {
} }
def fromJson(jsonStr: String): TypesDef = { def fromJson(jsonStr: String): TypesDef = {
implicit val formats = org.json4s.native.Serialization.formats(NoTypeHints) + new MultiplicitySerializer implicit val formats = _formats + new MultiplicitySerializer
read[TypesDef](jsonStr) read[TypesDef](jsonStr)
} }
def toJson(typesDef : TypesDef) : String = { def toJson(typesDef : TypesDef) : String = {
implicit val formats = org.json4s.native.Serialization.formats(NoTypeHints) + new MultiplicitySerializer implicit val formats = _formats + new MultiplicitySerializer
writePretty(typesDef) writePretty(typesDef)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment