javauis/javalegacyutils/src/CreateEpocTTime.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 jlong which is the number of milliseconds from the Java epoch time
       
    23 of 00:00 1st Jan 1970 and converts it into a EPOC TTime object */
       
    24 EXPORT_C TTime JavaEpocTime::CreateEpocTTime(jlong aJavaTime)
       
    25 {
       
    26     // Convert jlong to a TInt64
       
    27     TInt64 timeNum = *reinterpret_cast<TInt64*>(&aJavaTime);
       
    28     // Create a TTime object that represents the Java Date 'epoch' time of 00:00, 1 Jan 1970
       
    29     TInt64 javaEpocTimeNum = MAKE_TINT64(JavaUpperTimeFor1970, JavaLowerTimeFor1970);
       
    30     TTime time(javaEpocTimeNum);
       
    31     TTimeIntervalMicroSeconds delta(timeNum * 1000);
       
    32     return time + delta;
       
    33 }