I've read a lot of posts about this, but I cannot get it to work. I need a textView (id - datumprikaz ) to show the current date like this: 28.11.2016.
I've managed to add the date using this method in my java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView dateView = (TextView)findViewById(R.id.datumprikaz);
setDate(dateView);
}
public void setDate (TextView view){
String str = String.format("%tc", new Date());
view.setText(str);
}
The problem is I get as a result: Fri Oct 28 19:57:37 GMT
And I just need it to show the current date like 28.11.2016.
How do I do this ?
I've tried another method with
String trenutniDatum = DateFormat.getDateTimeInstance().format(new Date());
datumprikaz textView = (datumprikaz) findViewById(R.id.datumprikaz);
datumprikaz.setText(trenutniDatum);
But the setText is red and won't work.
How do I get this ? 28.11.2016 in a textView with the id datumprikaz