我有這段代碼。我需要轉換string
「horaTarefa HH:MM」到int
「小時= HH」和int
「分= MM」如何將「String HH:MM」轉換爲「int hour HH」和「int minute MM」
我想我可以做同樣的事情與「dateTarefa DD/MM/YYYY「?
SQLiteDatabase db;
db = openOrCreateDatabase("AgendadorTarefas.db",SQLiteDatabase.CREATE_IF_NECESSARY,null); { }
Cursor c = db.query("Tarefa", new String[] {
"codTarefa", "dateTarefa", "horaTarefa", "textoTarefa"},
null, null, null, null, null);
c.moveToFirst();
final ArrayList<String> result = new ArrayList<String>();
while(c.moveToNext())
{
String Date = c.getString(1);
String Hora = c.getString(2);
String Texto = c.getString(3);
result.add(Data + " às " + Hora + " \n" + Texto);
}
hour = Calendar.HOUR;
minute = Calendar.MINUTE;
c.close();
請考慮使用Java的專有名稱約定(如在本例中爲lowerCamelCase變量名稱)。這確實會提高代碼的可讀性,特別是在突出顯示的情況下。 – SapuSeven