本文整理汇总了Java中android.text.format.Time.format方法的典型用法代码示例。如果您正苦于以下问题:Java Time.format方法的具体用法?Java Time.format怎么用?Java Time.format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.format.Time
的用法示例。
在下文中一共展示了Time.format方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatTime
import android.text.format.Time; //导入方法依赖的package包/类
static public String formatTime(int ms) {
String res;
if (ms <= 0) {
res = EMPTY_STRING;
} else {
Time t = new Time();
t.set(ms);
t.switchTimezone(Time.TIMEZONE_UTC);
if (ms >= 3600000) {
res = t.format(TIME_HOUR);
} else if (ms < 60000)
res = t.format(TIME_SECOND);
else
res = t.format(TIME_MINUTE);
if (res.charAt(0) == '0') {
res = res.substring(1);
}
}
return res;
}
示例2: updateTime
import android.text.format.Time; //导入方法依赖的package包/类
private void updateTime() {
// TODO KIO Is this really necessary to creat a calendar?
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(mTest.getDate());
Log.d(TAG_KIO, "Inside updateTime() mDate time is: "
+ mTest.getDate().getTime());
Log.d(TAG_KIO, "Inside updateTime() mDate is: " + mTest.getDate());
Time time = new Time();
time.set(mTest.getDate().getTime());
String timeFormat = time.format("%I:%M");
Log.d(TAG_KIO, "timeFormat is: " + timeFormat);
mTimeButton.setText(timeFormat);
}
示例3: createNdefMessage
import android.text.format.Time; //导入方法依赖的package包/类
/**
* Implementation for the CreateNdefMessageCallback interface
*/
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
Time time = new Time();
time.setToNow();
String text = ("Beam me up!\n\n" +
"Beam Time: " + time.format("%H:%M:%S"));
NdefMessage msg = new NdefMessage(NdefRecord.createMime(
"application/com.example.android.beam", text.getBytes())
/**
* The Android Application Record (AAR) is commented out. When a device
* receives a push with an AAR in it, the application specified in the AAR
* is guaranteed to run. The AAR overrides the tag dispatch system.
* You can add it back in to guarantee that this
* activity starts when receiving a beamed message. For now, this code
* uses the tag dispatch system.
*/
//,NdefRecord.createApplicationRecord("com.example.android.beam")
);
return msg;
}
示例4: formatTime
import android.text.format.Time; //导入方法依赖的package包/类
public String formatTime(long ms) {
String res;
if (ms == 0) {
res = "";
} else {
Time t = new Time();
t.set(ms);
t.switchTimezone(Time.TIMEZONE_UTC);
if (ms >= 3600000) {
res = t.format("%kh%M'");
} else if (ms < 60000)
res = t.format("%S''");
else
res = t.format("%M'%S''");
if (res.charAt(0) == '0') {
res = res.substring(1);
}
}
return res;
}
示例5: getFile
import android.text.format.Time; //导入方法依赖的package包/类
private File getFile(final String suffix) {
Time time = new Time();
time.setToNow();
audioFilePath = time.format("%Y%m%d%H%M%S");
return new File(RECORD_WAV_PATH, time.format("%Y%m%d%H%M%S") + "." + suffix);
}