[DateFormat] 시간정보 가져오기
작업하다 보면 시작정보가 필요한 경우가 있다.
파일이름을 시간정보로 저장한다던지...^^
이때 간단히 사용할수 있는 것이 있다.
import java.util.Date;
import android.text.format.DateFormat;
String sTime = DateFormat.format("MM/dd/yy h:mmaa", new Date()).toString();
-------------------------------------------------------------------------
public class
DateFormat
extends Object
This class takes as inputs a format string and a representation of a date/time. The format string controls how the output is generated.
Formatting characters may be repeated in order to get more detailed representations of that field. For instance, the format character 'M' is used to represent the month. Depending on how many times that character is repeated you get a different representation.
For the month of September:
M -> 9
MM -> 09
MMM -> Sep
MMMM -> September
Examples for April 6, 1970 at 3:23am:
"MM/dd/yy h:mmaa" -> "04/06/70 3:23am"
"MMM dd, yyyy h:mmaa" -> "Apr 6, 1970 3:23am"
"MMMM dd, yyyy h:mmaa" -> "April 6, 1970 3:23am"
"E, MMMM dd, yyyy h:mmaa" -> "Mon, April 6, 1970 3:23am&
"EEEE, MMMM dd, yyyy h:mmaa" -> "Monday, April 6, 1970 3:23am"
"'Noteworthy day: 'M/d/yy" -> "Noteworthy day: 4/6/70"
'IT > Android[안드로이드]' 카테고리의 다른 글
[Activity #2] startActivityForResult (0) | 2010.12.06 |
---|---|
[Serializable] 객체를 파일에 쓰고 읽기 (0) | 2010.12.03 |
[Activity #1] onSaveInstanceState() (0) | 2010.12.02 |
[Intent #1] Activity에 기본 데이타 전달하기 (0) | 2010.12.01 |
[Intent #2] Activity간 정보 전달 [Parcelable] (0) | 2010.12.01 |