diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp
index 1ced55343ee9..c0dbfcc216b9 100644
--- a/src/android/jpeg/exif.cpp
+++ b/src/android/jpeg/exif.cpp
@@ -186,9 +186,11 @@ void Exif::setSize(const Size &size)
 
 void Exif::setTimestamp(time_t timestamp)
 {
+	struct tm tm;
+	localtime_r(&timestamp, &tm);
+
 	char str[20];
-	std::strftime(str, sizeof(str), "%Y:%m:%d %H:%M:%S",
-		      std::localtime(&timestamp));
+	strftime(str, sizeof(str), "%Y:%m:%d %H:%M:%S", &tm);
 	std::string ts(str);
 
 	setString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts);
diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h
index 622de4cfd593..f04cefcea74a 100644
--- a/src/android/jpeg/exif.h
+++ b/src/android/jpeg/exif.h
@@ -7,8 +7,8 @@
 #ifndef __ANDROID_JPEG_EXIF_H__
 #define __ANDROID_JPEG_EXIF_H__
 
-#include <ctime>
 #include <string>
+#include <time.h>
 
 #include <libexif/exif-data.h>
 
