I need to display the current time in a textview and the time changes dynamically for every second (Like the digital clock) in android.. I have googled but i didnt get the help.If Anyone have the idea for this, please help me Thanks in advance.
Date; Date currentTime = Calendar. getInstance(). getTime();
text. DateFormat. getDateTimeInstance(). format(new Date()); // textView is the TextView view that should display it textView.
Use TextClock. this wil change dynamically without having a separate code.
<TextClock
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textClock"
android:layout_weight="0.11"
android:textStyle="bold"
android:textSize="22sp"
android:format24hours="hh:mm:ss a EEE MMM d"/>
TextClock textClock = (TextClock) findViewById(R.id.textClock);
textClock.setFormat12Hour(null);
//textClock.setFormat24Hour("dd/MM/yyyy hh:mm:ss a");
textClock.setFormat24Hour("hh:mm:ss a EEE MMM d");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With