diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/NativeMethods.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/NativeMethods.java index 55ca15691..107b8b729 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/NativeMethods.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/NativeMethods.java @@ -153,6 +153,15 @@ public class NativeMethods } } + @SuppressWarnings(Const.JNI_METHOD_SUPPRESS) + public static String getFormattedDateTime() + { + String currentDate = new SimpleDateFormat((new SimpleDateFormat()).toLocalizedPattern(), Locale.getDefault()).format(new Date()); + String currentTime = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(new Date()); + + return currentDate + " " + currentTime; + } + private static void internalProgressDisplay(final boolean show) { final Context ctx = SDL.getContext(); diff --git a/lib/vstd/DateUtils.cpp b/lib/vstd/DateUtils.cpp index da098aa20..ebf7a5722 100644 --- a/lib/vstd/DateUtils.cpp +++ b/lib/vstd/DateUtils.cpp @@ -1,6 +1,10 @@ #include "StdInc.h" #include +#if defined(VCMI_ANDROID) +#include "../CAndroidVMHelper.h" +#endif + VCMI_LIB_NAMESPACE_BEGIN namespace vstd @@ -8,6 +12,11 @@ namespace vstd DLL_LINKAGE std::string getFormattedDateTime(std::time_t dt) { +#if defined(VCMI_ANDROID) + CAndroidVMHelper vmHelper; + return vmHelper.callStaticStringMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "getFormattedDateTime"); +#endif + std::tm tm = *std::localtime(&dt); std::stringstream s; try