Reputation: 808
i searched a lot to find how initialize Time variables in my Android project, i have tried to use Set(); methode but doesn't work, i need your help thank's ` here is my source code :
TableRow tableRow;
Time HourProgram;
int H = 12000, M = 1200;
int averageConsultationTime = 30;
// String
// TableSettinHourgHeader=""+HourBegen+"H"+averageConsultationTime+"|"
// +HourBegen+"H"+averageConsultationTime+"|"
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table);
Log.i("OK", "onCreateOK");
Log.i("OK", "HMOK");
TextView DynamicButton = new TextView(MainActivity.this);
tableRow = (TableRow) findViewById(R.id.tr1);
LayoutParams layoutparams = new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
DynamicButton.setLayoutParams(layoutparams);
String ss = converteur(H, M);
Log.i("OK", "converteur(H, M)OK" + ss);
DynamicButton.setText("Assalam Aleikum " + ss);
Log.i("OK", "setTextOK" + ss);
tableRow.addView(DynamicButton);
}
@SuppressWarnings("unused")
private String converteur(int timeBegen, int averageConsultationTime) {
String sTb = "" + String.valueOf(timeBegen).toString();
String sAct = ""
+ String.valueOf(this.averageConsultationTime).toString();
// Toast.makeText(this,
// ""+timeBegen+"H"+averageConsultationTime,Toast.LENGTH_LONG);
return "timeBegen : " + sTb + " averageConsultationTime : "
+ averageConsultationTime;
}
`
Upvotes: 0
Views: 1345
Reputation: 6704
For
java.sql.Time
It should be
Time HourProgram = new Time(System.currentTimeMillis());
Also, if you prefer Calendar then,
Time HourProgram = new Time(Calendar.getInstance().getTimeInMillis());
Upvotes: 1