diff --git a/pythonPackages/dynamicserialize/adapters/FormattedDateAdapter.py b/pythonPackages/dynamicserialize/adapters/FormattedDateAdapter.py new file mode 100644 index 0000000000..f8c6b961f0 --- /dev/null +++ b/pythonPackages/dynamicserialize/adapters/FormattedDateAdapter.py @@ -0,0 +1,46 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# Adapter for FormattedDate +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 9/21/2015 4486 rjpeter Initial creation. +# +# +# + +from dynamicserialize.dstypes.com.raytheon.uf.common.time import FormattedDate + + +ClassAdapter = 'com.raytheon.uf.common.time.FormattedDate' + +def serialize(context, date): + context.writeI64(date.getTime()) + +def deserialize(context): + result = FormattedDate() + result.setTime(context.readI64()) + return result \ No newline at end of file diff --git a/pythonPackages/dynamicserialize/adapters/__init__.py b/pythonPackages/dynamicserialize/adapters/__init__.py index fdf496f84c..c3eba34793 100644 --- a/pythonPackages/dynamicserialize/adapters/__init__.py +++ b/pythonPackages/dynamicserialize/adapters/__init__.py @@ -32,7 +32,7 @@ # 04/22/13 #1949 rjpeter Added LockTableAdapter # 02/06/14 #2672 bsteffen Added JTSEnvelopeAdapter # 06/22/2015 #4573 randerso Added JobProgressAdapter -# +# 09/21/2015 #4486 rjpeter Added FormattedDateAdapter # __all__ = [ @@ -43,6 +43,7 @@ __all__ = [ 'GregorianCalendarAdapter', 'ActiveTableModeAdapter', 'DateAdapter', + 'FormattedDateAdapter', 'LocalizationLevelSerializationAdapter', 'LocalizationTypeSerializationAdapter', 'GeometryTypeAdapter', diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/FormattedDate.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/FormattedDate.py new file mode 100644 index 0000000000..56cbafacfd --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/FormattedDate.py @@ -0,0 +1,39 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# ---------------------------------------------------------------------------- +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 09/21/2015 4486 rjpeter Initial creation. +# +## + +from time import gmtime, strftime +from dynamicserialize.dstypes.java.util import Date + +class FormattedDate(Date): + + def __init__(self, timeInMillis=None): + super(FormattedDate, self).__init__(timeInMillis) + + def __repr__(self): + return strftime("%Y-%m-%d %H:%M:%S.", gmtime(self.time/1000.0)) + '{:03d}'.format(self.time%1000) diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py index 2ca8389f3f..6aa24f6307 100644 --- a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py @@ -22,9 +22,11 @@ __all__ = [ 'DataTime', - 'TimeRange' + 'TimeRange', + 'FormattedDate' ] from DataTime import DataTime from TimeRange import TimeRange +from FormattedDate import FormattedDate