【发布时间】:2018-02-08 15:47:44
【问题描述】:
我有使用const struct tm myTimeInfo 操作的JNI 方法。最后,我想将结果返回给 Java。但是,我不能直接返回Date。到目前为止,我将struct tm 转换为jstring 并在java 中转换回Date,这似乎很奇怪。有没有办法直接返回Date填满struct tm?
我目前的解决方案是这样的:
JNIEXPORT jstring JNICALL package_getTimeLineEndUTC(JNIEnv *env, jobject thiz) {
const struct tm timeInfo = generateTime();
return env->NewStringUTF(asctime(&timeInfo));
}
【问题讨论】:
标签: java android c++ c java-native-interface