javauis/javalegacyutils/src/CreateJavaTime.cpp
changeset 76 4ad59aaee882
parent 69 773449708c84
child 79 2f468c1958d0
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
     1 /*
       
     2 * Copyright (c) 1999-2000 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "jutils.h"
       
    20 
       
    21 //----------------------------------------------------------------------------
       
    22 /* Takes a TTime and returns the number of milliseconds since the Java epoch time
       
    23 of 00:00 1st Jan 1970 */
       
    24 EXPORT_C jlong JavaEpocTime::CreateJavaTime(TTime aEpocTime)
       
    25 {
       
    26     // Create a TTime object that represents the Java Date 'epoch' time of 00:00, 1 Jan 1970
       
    27     TInt64 javaEpocTimeNum = MAKE_TINT64(JavaUpperTimeFor1970, JavaLowerTimeFor1970);
       
    28     TTime javaEpochTime(javaEpocTimeNum);
       
    29     // Find difference in microseconds between 'epoch' and EPOC date and adjust to milliseconds
       
    30     TTimeIntervalMicroSeconds microInterval = aEpocTime.MicroSecondsFrom(javaEpochTime);
       
    31     TInt64 intervalNum = microInterval.Int64();
       
    32     intervalNum /= 1000;
       
    33     jlong jInterval = *reinterpret_cast<jlong*>(&intervalNum);
       
    34     return jInterval;
       
    35 }