MakeCSharpDate() 공개 정적인 메소드

Makes a C# DateTime object from a Java ticks value from java.util.Date.getTime().
public static MakeCSharpDate ( long javaDate ) : System.DateTime
javaDate long
리턴 System.DateTime
예제 #1
0
        /// <summary>
        /// Reads an arbitrary object from the input stream.
        /// </summary>
        /// <returns>Read object</returns>
        /// <exception cref="CHessianException"/>
        public override object ReadObject()
        {
            int intTag = Read();

            switch (intTag)
            {
            case PROT_NULL:
                return(null);

            case PROT_BOOLEAN_TRUE:
                return(true);

            case PROT_BOOLEAN_FALSE:
                return(false);

            case PROT_INTEGER_TYPE:
                return(ParseInt());

            case PROT_LONG_TYPE:
                return(ParseLong());

            case PROT_DOUBLE_TYPE:
                return(ParseDouble());

            case PROT_STRING_INITIAL:
            case PROT_STRING_FINAL:
            {
                m_blnIsLastChunk = intTag == PROT_STRING_FINAL;
                m_intChunkLength = (Read() << 8) + Read();
                return(LoadString());
            }

            case PROT_MAP_TYPE:
            {
                String strType = ReadType();
                return(m_serializerFactory.ReadMap(this, strType));
            }

            case PROT_DATE_TYPE:
            {
                /*
                 * Eine Windows-Dateizeit ist ein 64-Bit-Wert, der die Anzahl
                 * von 100-Nanosekunden-Intervallen darstellt, die seit 1. Januar 1601,
                 * 00:00 u. Z. koordinierter Weltzeit (Coordinated Universal Time, UTC)
                 * verstrichen sind.  */
                long javaTime = ParseLong();
                return(CDateDeserializer.MakeCSharpDate(javaTime));
            }

            case PROT_REF_TYPE:
            {
                int intRefNumber = ParseInt();
                return(m_arrRefs[intRefNumber]);
            }

            case 'r':
            {
                throw new CHessianException("remote type is not implemented");
            }

#if !COMPACT_FRAMEWORK
            case PROT_XML_INITIAL:
            case PROT_XML_FINAL:
            {
                m_blnIsLastChunk = intTag == PROT_XML_FINAL;
                m_intChunkLength = (Read() << 8) + Read();
                return(parseXML());
            }
#endif
            case PROT_BINARY_START:
            case PROT_BINARY_END:
            {
                m_blnIsLastChunk = intTag == PROT_BINARY_END;
                m_intChunkLength = (Read() << 8) + Read();

                int          intData;
                MemoryStream memoryStream = new MemoryStream();
                while ((intData = ParseByte()) >= 0)
                {
                    memoryStream.WriteByte((byte)intData);
                }
                return(memoryStream.ToArray());
            }

            case PROT_LIST_TYPE:
            {
                string strType   = this.ReadType();
                int    intLength = this.ReadLength();
                return(m_serializerFactory.ReadList(this, intLength, strType));
            }

            default:
                throw new CHessianException("unknown code:" + (char)intTag);
            }
        }
예제 #2
0
        /// <summary>
        /// Reads the basic (primitive & Date ) data types
        /// and arrays of them
        /// </summary>
        /// <param name="abstractHessianInput">Hessian Input instance</param>
        /// <exception cref="CHessianException"/>
        /// <returns>Read object</returns>
        public override object ReadObject(AbstractHessianInput abstractHessianInput)
        {
            switch (m_intCode)
            {
            case BOOLEAN:
                return(abstractHessianInput.ReadBoolean());

            case BYTE:
                return((byte)abstractHessianInput.ReadInt());

            case SBYTE:
                return((sbyte)abstractHessianInput.ReadInt());

            case FLOAT:
                return((float)abstractHessianInput.ReadDouble());

            case SHORT:
                return((short)abstractHessianInput.ReadInt());

            case INTEGER:
                return(abstractHessianInput.ReadInt());

            case LONG:
                return(abstractHessianInput.ReadLong());

            case DOUBLE:
                return(abstractHessianInput.ReadDouble());

            case STRING:
                return(abstractHessianInput.ReadString());

            case CHARACTER:
            {
                //int charResult = abstractHessianInput.ReadInt();
                //return (char)charResult;
                //Bei caucho ist hier ein Bug
                //TODO:Test
                string strResult = abstractHessianInput.ReadString();
                if (strResult == null || strResult.Length == 0)
                {
                    return(null);
                }
                else
                {
                    return(strResult[0]);
                }
            }

            case BOOLEAN_ARRAY:
            case SHORT_ARRAY:
            case INTEGER_ARRAY:
            case SBYTE_ARRAY:
            case LONG_ARRAY:
            case FLOAT_ARRAY:
            case DOUBLE_ARRAY:
            case STRING_ARRAY:
            {
                if (abstractHessianInput.ReadListStart() == 'N')
                {
                    return(null);
                }

                abstractHessianInput.ReadType();
                int intLength = abstractHessianInput.ReadLength();

                return(ReadList(abstractHessianInput, intLength));
            }

            case BYTE_ARRAY:
                return(abstractHessianInput.ReadBytes());

            case CHARACTER_ARRAY:
            {
                string strResult = abstractHessianInput.ReadString();

                if (strResult == null)
                {
                    return(null);
                }
                else
                {
                    int     intLength = strResult.Length;
                    char [] arrChars  = new char[intLength];
                    arrChars = strResult.ToCharArray();
                    return(arrChars);
                }
            }

            case DATE:
                long javaTime = abstractHessianInput.ReadUTCDate();
                return(CDateDeserializer.MakeCSharpDate(javaTime));

            default:
                throw new CHessianException("not supperted type for deserialization");
            }
        }