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); }
原文:http://www.cnblogs.com/AndroidCSY/p/6681525.html