<small id='yIuRV'></small><noframes id='yIuRV'>

<tfoot id='yIuRV'></tfoot>

    <i id='yIuRV'><tr id='yIuRV'><dt id='yIuRV'><q id='yIuRV'><span id='yIuRV'><b id='yIuRV'><form id='yIuRV'><ins id='yIuRV'></ins><ul id='yIuRV'></ul><sub id='yIuRV'></sub></form><legend id='yIuRV'></legend><bdo id='yIuRV'><pre id='yIuRV'><center id='yIuRV'></center></pre></bdo></b><th id='yIuRV'></th></span></q></dt></tr></i><div id='yIuRV'><tfoot id='yIuRV'></tfoot><dl id='yIuRV'><fieldset id='yIuRV'></fieldset></dl></div>
  1. <legend id='yIuRV'><style id='yIuRV'><dir id='yIuRV'><q id='yIuRV'></q></dir></style></legend>
        <bdo id='yIuRV'></bdo><ul id='yIuRV'></ul>

      发送数据时,从 Android 应用中的 Firebase 检索 Se

      时间:2023-07-25

        <bdo id='gnuGK'></bdo><ul id='gnuGK'></ul>
            <tbody id='gnuGK'></tbody>

            <i id='gnuGK'><tr id='gnuGK'><dt id='gnuGK'><q id='gnuGK'><span id='gnuGK'><b id='gnuGK'><form id='gnuGK'><ins id='gnuGK'></ins><ul id='gnuGK'></ul><sub id='gnuGK'></sub></form><legend id='gnuGK'></legend><bdo id='gnuGK'><pre id='gnuGK'><center id='gnuGK'></center></pre></bdo></b><th id='gnuGK'></th></span></q></dt></tr></i><div id='gnuGK'><tfoot id='gnuGK'></tfoot><dl id='gnuGK'><fieldset id='gnuGK'></fieldset></dl></div>
          1. <tfoot id='gnuGK'></tfoot>

              <legend id='gnuGK'><style id='gnuGK'><dir id='gnuGK'><q id='gnuGK'></q></dir></style></legend>
              1. <small id='gnuGK'></small><noframes id='gnuGK'>

              2. 本文介绍了发送数据时,从 Android 应用中的 Firebase 检索 ServerValue.Timestamp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我想知道如何使用 Firebase 的 ServerValue.TIMESTAMP 方法,当我想在 Firebase 服务器上创建时间戳,然后将其检索到本地客户端.

                I would like to know how to use Firebase's ServerValue.TIMESTAMP method, when I want to create a timestamp at the Firebase server, and then retrieve it to the local client.

                在 Firebase 指南中,只有 javascript 对此案例有更详细的描述,但我很难弄清楚如何将其转换为我的 Android 应用程序.

                In Firebase guides, only javascript has a more detailed description of this case, but I'm having a hard time figureing how to translate this in to my Android appliction.

                提前致谢!

                推荐答案

                Firebase.ServerValue.TIMESTAMP 设置为 Map(包含 {.sv:"timestamp"}) 告诉 Firebase 用服务器的时间填充该字段.当该数据被读回时,它是实际的 unix 时间戳,它是一个 Long.

                Firebase.ServerValue.TIMESTAMP is set as a Map (containing {.sv: "timestamp"}) which tells Firebase to populate that field with the server's time. When that data is read back, it is the actual unix time stamp which is a Long.

                这样的事情会起作用:

                Firebase ref = new Firebase("https://YOUR-FIREBASE.firebaseio.com");    
                
                ref.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot snapshot) {
                        Long timestamp = (Long) snapshot.getValue();
                        System.out.println(timestamp);
                    }
                
                    @Override
                    public void onCancelled(DatabaseError databaseError) {
                
                    }
                });
                
                ref.setValue(ServerValue.TIMESTAMP);
                

                再举一个例子,你可以看看我对这个问题的回答:Android 聊天在 DataSnapshot.getValue() 上崩溃

                For another example, you can see my answer to this question: Android chat crashes on DataSnapshot.getValue() for timestamp

                这篇关于发送数据时,从 Android 应用中的 Firebase 检索 ServerValue.Timestamp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使 java.sql.Timestamp UTC 时间? 下一篇:为什么我的 System.nanoTime() 坏了?

                相关文章

                最新文章

                <legend id='Sc89C'><style id='Sc89C'><dir id='Sc89C'><q id='Sc89C'></q></dir></style></legend>
                  <bdo id='Sc89C'></bdo><ul id='Sc89C'></ul>

              3. <tfoot id='Sc89C'></tfoot>

              4. <small id='Sc89C'></small><noframes id='Sc89C'>

              5. <i id='Sc89C'><tr id='Sc89C'><dt id='Sc89C'><q id='Sc89C'><span id='Sc89C'><b id='Sc89C'><form id='Sc89C'><ins id='Sc89C'></ins><ul id='Sc89C'></ul><sub id='Sc89C'></sub></form><legend id='Sc89C'></legend><bdo id='Sc89C'><pre id='Sc89C'><center id='Sc89C'></center></pre></bdo></b><th id='Sc89C'></th></span></q></dt></tr></i><div id='Sc89C'><tfoot id='Sc89C'></tfoot><dl id='Sc89C'><fieldset id='Sc89C'></fieldset></dl></div>