Examples of using String.format() to display formatted calendar
package com.panayiotisgeorgiou.androidtime;
import java.util.Calendar;
import android.support.v7.app.ActionBarActivity;
import android.widget.TextView;
import android.os.Bundle;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView cal = (TextView)findViewById(R.id.cal);
Calendar calendar = Calendar.getInstance();
cal.setText(
String.format(“%td-%tm-%tYn”, calendar, calendar, calendar) +
String.format(“%ty/%tm/%tdn”, calendar, calendar, calendar) +
String.format(“%tI:%tM:%tS %tpn”, calendar, calendar, calendar, calendar) +
“n” +
String.format(“%tDn”, calendar) +
String.format(“%tcn”, calendar) +
String.format(“%tFn”, calendar) +
String.format(“%trn”, calendar)
);
}
}