Hi all, first post so go easy on me. I've been trying to program for 3+ years now and still very much a Noob.
I'm trying to return a date as a string but I keep getting a null value.
I've tried several different ways to fix this without any success. I know it's something simple I'm doing wrong but I can't put my finger on it. Any help would be appreciated.
getDateTime();
balanceToDatabase(balance, strId);
helper.insertIntoPaid(strId, amountpaid, dateTime, "Notes Paid", "Spare 1", "Spare 2", "Spare 3"); //insert into paid table
btnPaid.setClickable(false); // so paid button can't be pressed again to avoid mistakes
Toast.makeText((getApplicationContext()), "£" + amountpaid + " paid has been recorded!", Toast.LENGTH_SHORT).show();
}
public void balanceToDatabase (String amountResultStr, String strId){
ContentValues newValues = new ContentValues();
newValues.put("balance", amountResultStr);
SQLiteDatabase db= helper.getWritableDatabase();
db.update("customers", newValues, "_id="+ strId, null);
db.close();
}
public String getDateTime() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String dateTime = df.format(c.getTime());
// formattedDate have current date/time
Toast.makeText(this, dateTime, Toast.LENGTH_SHORT).show();
return dateTime;
}
I'm trying to return a date as a string but I keep getting a null value.
I've tried several different ways to fix this without any success. I know it's something simple I'm doing wrong but I can't put my finger on it. Any help would be appreciated.
getDateTime();
balanceToDatabase(balance, strId);
helper.insertIntoPaid(strId, amountpaid, dateTime, "Notes Paid", "Spare 1", "Spare 2", "Spare 3"); //insert into paid table
btnPaid.setClickable(false); // so paid button can't be pressed again to avoid mistakes
Toast.makeText((getApplicationContext()), "£" + amountpaid + " paid has been recorded!", Toast.LENGTH_SHORT).show();
}
public void balanceToDatabase (String amountResultStr, String strId){
ContentValues newValues = new ContentValues();
newValues.put("balance", amountResultStr);
SQLiteDatabase db= helper.getWritableDatabase();
db.update("customers", newValues, "_id="+ strId, null);
db.close();
}
public String getDateTime() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String dateTime = df.format(c.getTime());
// formattedDate have current date/time
Toast.makeText(this, dateTime, Toast.LENGTH_SHORT).show();
return dateTime;
}