javacommons/utils/src.linux/formatternative.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 16:30:29 +0300
branchRCL_3
changeset 14 04becd199f91
permissions -rw-r--r--
Revision: v2.1.22 Kit: 201017

/*
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  formatternative
*
*/


#include <time.h>

#include "com_nokia_mj_impl_utils_Formatter.h"
#include "com_nokia_mj_impl_utils_ResourceLoader.h"
#include "javacommonutils.h"
#include "javajniutils.h"
#include "logger.h"

JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatInteger
(JNIEnv *aJni, jobject, jint aNumber)
{
    // Stub implementation
    std::string intStr = java::util::JavaCommonUtils::intToString(aNumber);
    return aJni->NewStringUTF(intStr.c_str());
}

JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDate
(JNIEnv * aJni, jobject, jlong timeInMillis)
{
    // Stub implementation. Missing localisation.
    time_t javaTime = timeInMillis/1000;
    char buffer[80];
    struct tm* timeInfo;
    timeInfo = localtime(&javaTime);

    // European format as default.
    strftime(buffer, 80, "%d/%m/%Y", timeInfo);

    std::string dateStr(buffer);

    return aJni->NewStringUTF(dateStr.c_str());
}

JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_utils_ResourceLoader__1getLocaleId
(JNIEnv *, jobject)

{
    // Stub implementation. This triggers using default "sc" engineering
    // english at Java side.
    return (jint) -1;
}