从日期选择器对话框片段中获取字符串

时间:2013-11-22 18:29:35

标签: android android-layout android-datepicker

我正在使用the example from the documentation

从方法

public void onDateSet(DatePicker view, int year, int month, int day) {
    // Do something with the date chosen by the user
}

我想要字符串“Mon,Sep 14,2014”。我怎么得到它?理想情况下,我真的想要“星期一,2014年9月14日晚上10:30”,但我找不到合并的日期和时间选择器。

2 个答案:

答案 0 :(得分:1)

这里结合日期时间。

这并不意味着只是说你说你找不到它。

如何找到它:http://bit.ly/1doSxEf

我使用哪一个:

https://github.com/bendemboski/DateSlider

答案 1 :(得分:0)

// try this way 
public void onDateSet(DatePicker view, int year,int monthOfYear, int dayOfMonth) {
 Time chosenDate = new Time();
 chosenDate.set(dayOfMonth, monthOfYear, year);
 long dt = chosenDate.toMillis(true);
 CharSequence strDate = DateFormat.format("KKK MMM dd,yyyy", dt);
 // mow use  strDate..
}
相关问题