我搜索了很多,以找到如何在我的Android项目中初始化时间变量,我试图使用Set();方法但不起作用,我需要你的帮助谢谢'这里是我的源代码:
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;
}
`
答案 0 :(得分:1)
对于
的java.sql.Time
应该是
Time HourProgram = new Time(System.currentTimeMillis());
此外,如果您更喜欢日历,
Time HourProgram = new Time(Calendar.getInstance().getTimeInMillis());