Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Android Java: Aktuelles Datum darstellen

20.09.2018 (👁172)


 

 

Lösung 1:

//-< Current Time >-

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
String now = sdf.format(
new Date());
//-</ Current Time >-

 

 

 

 

 

Java Code:

public void create_Table(){
       
//-------< create_Table() >--------
       
TableLayout tbl=findViewById(R.id.table_main);

        
//--< Row >--
       
TableRow row=new TableRow(this);
        row.setPadding(
2,2,2,2);

       
//< cell1 >
//        Time now = Time.;
//        now.getTime();
        //-< Current Time >-
       
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
        String now = sdf.format(
new Date());
       
//-</ Current Time >-

       
TextView lbl1=new TextView(this);
        lbl1.setText(now);
        lbl1.setTextColor(Color.
RED);
        lbl1.setBackgroundColor(Color.
YELLOW);
        row.addView(lbl1);
       
//</ cell1 >

        //< cell2 >
       
TextView lbl2=new TextView(this);
        Drawable back1= getDrawable(R.drawable.
table_layout);
        lbl1.setBackground(back1);

        row.addView(lbl2);
       
//</ cell1 >
        //--</ Row >--

        //< add to table >
       
tbl.addView(row);
       
//</ add to table >
        //-------</ create_Table() >--------
   
}