zoukankan      html  css  js  c++  java
  • Android基础TOP2_1:输出系统时间

    Activity:

        <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />

      JAVA:

     //获取TextView
            TextView tv=(TextView)findViewById(R.id.tv);
            //调用Date类
            Date now=new Date();
            //设置时间显示格式
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
            String sj=sdf.format(now);
            tv.setText("现在时间:"+sj);
            }

     //获取TextView
            TextView tv=(TextView)findViewById(R.id.tv);
            //调用Date类
            Date now=new Date();
            //设置时间显示格式
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
            String sj=sdf.format(now);
            tv.setText("现在时间:"+sj);
            }
  • 相关阅读:
    CentOS7修改计算机名!
    kafka原理和实践
    sip协议详解
    MP4视频测试URL地址,亲测有效
    pkill精确匹配进程名称
    gdb break 断点设置
    ZR#996
    CF1217C
    CF1217B
    CF1217A
  • 原文地址:https://www.cnblogs.com/AndroidCSY/p/6681525.html
Copyright © 2011-2022 走看看