小编May*_*aya的帖子

将当前日期转换为整数

我想将当前日期转换为整数形式.默认情况下,它返回long.当我尝试将long转换为整数,然后我将整数值转换为日期意味着它显示1970年的日期.

 int i = (int) new Date().getTime();
 System.out.println("Integer : " + i);
 System.out.println("Long : "+ new Date().getTime());
 System.out.println("Long date : " + new Date(new Date().getTime()));
 System.out.println("Int Date : " + new Date(i));
Run Code Online (Sandbox Code Playgroud)

输出将成为

Integer : 1292838124
Long : 1345617601771
Long date : Wed Aug 22 12:10:01 IST 2012
Int Date : Fri Jan 16 04:37:18 IST 1970
Run Code Online (Sandbox Code Playgroud)

任何人请帮助我,如何将当前日期转换为整数(10位数字)

java date

28
推荐指数
4
解决办法
18万
查看次数

Android SQLite数据库在活动之间共享

在多个活动之间共享一个SQLite DB的最佳方法是什么?数据库中的表显示在ListView中,并且还要执行删除/插入记录.我听说过有关服务的事情,但没有找到任何关于我的问题的例子.现在我有SQLiteOpenHelper类来打开数据库.我在OnPause()中关闭数据库并在onResume()中打开它.但我不能从子活动向数据库插入数据,出了点问题.

sqlite android

10
推荐指数
1
解决办法
2万
查看次数

从Android应用程序调用异步Firebase函数时获取“内部”异常

我正在尝试从android应用程序调用异步Firebase函数,并在该函数返回时获取“ INTERNAL”异常。

Android:

 private Task<String> fetchData() {
    // Create the arguments to the callable function, which is just one string
    Map<String, Object> data = new HashMap<>();
    data.put(“id”, “abc”);

    return FirebaseFunctions.getInstance()
            .getHttpsCallable(“calculate”)
            .call(data)
            .continueWith(new Continuation<HttpsCallableResult, String>() {
                @Override
                public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
                    Map<String, Object> result = (Map<String, Object>) task.getResult().getData();
                    return (String)result.get(“data”);
                }
            });
 }
Run Code Online (Sandbox Code Playgroud)

Firebase功能:

exports.calculate = functions.https.onCall((data, context) => {
    const text = data.id;
    return calc.calculate( (err, response) => {
        if(err) {
            // handle error
        } …
Run Code Online (Sandbox Code Playgroud)

android asynchronous firebase google-cloud-functions

2
推荐指数
1
解决办法
1787
查看次数