Android_Date显示时间格式_141027
来源:互联网 发布:linux启动ntp服务命令 编辑:程序博客网 时间:2024/06/10 14:56
本文主要介绍一下 android的时间显示的一些 固定的格式
不多说,上代码
// SampleActivity.java
package com.yline.dateshow;import java.util.Calendar;import android.app.Activity;import android.os.Bundle;import android.text.format.DateFormat;import android.widget.TextView;public class SampleActivity extends Activity{@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textView1 = (TextView) findViewById(R.id.textView1); TextView textView2 = (TextView) findViewById(R.id.textView2); TextView textView3 = (TextView) findViewById(R.id.textView3); TextView textView4 = (TextView) findViewById(R.id.textView4); TextView textView5 = (TextView) findViewById(R.id.textView5); java.util.Date noteTS = Calendar.getInstance().getTime(); String delegate = "MM//dd//yyyy hh:mm aa"; // 09/21/2014 02:17 pm textView1.setText("Found Time :: "+DateFormat.format(delegate, noteTS)); delegate = "MMM dd,yyyy h:mm aa"; // sep 21,2014 02:17 pm textView2.setText("Found Time :: "+DateFormat.format(delegate, noteTS)); delegate = "MMMM dd,yyyy h:mmaa"; // september 21,2014 02:17pm textView3.setText("Found Time :: "+DateFormat.format(delegate, noteTS)); delegate = "E,MMMM dd,yyyy h:mm:ss aa"; // wed,septempber 21,2014 02:17:48 pm textView4.setText("Found Time :: "+DateFormat.format(delegate, noteTS)); delegate = "EEEE,MMMM dd,yyyy h:mm:ss aa"; // wednesday,septempber 21,2014 02:17:48 pm textView5.setText("Found Time :: "+DateFormat.format(delegate, noteTS)); }}
// activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dip" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dip" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dip" /> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dip" /> <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dip" /></LinearLayout>运行图:
本文代码下载:(可运行)
http://pan.baidu.com/s/1GoS9K
0 0
- Android_Date显示时间格式_141027
- 时间显示格式
- sqlserver时间显示格式
- history显示时间格式
- java时间显示格式
- 时间显示格式
- jquery显示时间格式
- 解决DataGrid显示时间格式
- 不同的时间格式 显示
- 自定义系统时间显示格式
- jqGrid定制显示时间格式
- shell 按格式显示时间
- 时间格式的显示 format
- android 系统时间显示格式
- jsp页面时间显示格式
- 自定义 WordPress 时间显示格式
- smarty自定义时间显示格式
- php时间显示格式参数
- C 编译、链接、加载
- linux 学习日记一——ubuntu14.04安装
- 维度约间
- POJ 1860 Currency Exchange(最短路)
- codeforces 327A
- Android_Date显示时间格式_141027
- Linux下无法使用vpn解决方案
- Paypal学习 1 -- Buy now 按钮
- 开出博客第一天
- 第八周 项目4 个人所得税
- 迁移学习
- Shallow heap & Retained heap
- 自学python-django已经有一段时间。从今天开始写博客记录点滴经验与大家分享。
- IOS8定位服务