Home How to update the current time and Date on each click in string
Reply: 0

How to update the current time and Date on each click in string

user1371 Published in July 18, 2018, 6:25 am

I'm trying to populate my child elements in firebase with current Date and Time from following code

   SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String millisInString  = dateFormat.format(new Date());

    btn_send_msg.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

            Map<String,Object> map = new HashMap<String, Object>();
            temp_key = root.push().getKey();

            DatabaseReference message_root = root.child(temp_key);
            Map<String,Object> map2 = new HashMap<String, Object>();


But My problem is , it alwasy return and save the single time

for Example if I click then It will save

2018-04-16 10:17:54

and again if I click it will save the same time

2018-04-16 10:17:54

But If I restart my app and now if I click then it will save the new updated time,

2018-04-16 10:18:54

and same time again unless if I restart my app again.

Please help

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.39112 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO