這主要適用於android,但可以在Java中使用。我有這些聽衆:在Java中將整數日期/時間轉換爲unix時間戳?
int year, month, day, hour, minute;
// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
year = year;
month = monthOfYear;
day = dayOfMonth;
}
};
// the callback received when the user "sets" the time in the dialog
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
hour = hourOfDay;
minute = minute;
}
};
我怎麼能轉換int year, month, day, hour, minute;
爲unix時間戳?這可能沒有Date
類?
你爲什麼不想要使用日期類? – Falmarri 2011-01-12 21:22:57
爲了避免創建Date對象,如下所述:http://stackoverflow.com/questions/732034/getting-unixtime-in-java – 2011-01-12 21:29:12