---
title: "Fix the time from DigitalClock?"  
description: "Fix the time from DigitalClock?"  
author: "Anonymous User"  
published: 2014-10-14  
updated: 2014-10-14  
canonical: https://www.mindstick.com/forum/2379/fix-the-time-from-digitalclock  
category: "android"  
tags: ["android", "mobile development"]  
reading_time: 2 minutes  

---

# Fix the time from DigitalClock?

For example, I have DigitalClock and [TextView](https://www.mindstick.com/forum/23237/how-do-i-center-text-horizontally-and-vertically-in-a-textview-in-android) in MainActivity. How to [fix](https://yourviews.mindstick.com/view/80763/donald-trump-ki-jeet-fix-hai) time in TextView (24-hour [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format)) in a moment of time when the [Application](https://www.mindstick.com/articles/12824/calculator-application-in-android) is launched?\

## Replies

### Reply by Takeshi Okada

You can try this :\

```
String time= "Time : "  + DateFormat.getTimeFormat(getContext()).format(new Date(calendar.getTimeInMillis()));
```

\

This will return to the user smth like : " Time : 13:11"

Assuming you are using an instance of calendar somewhere in your code.

If not simply get an instance of calendar like this (it will return current device time ) :

Calendar calendar = Calendar.getInstance();

### Reply by Anonymous User

```
public class ApplicationController extends Application{        /**         * A singleton instance of the application class for easy access in other places         */        private static ApplicationController sInstance;        public static synchronized ApplicationController getInstance() {            return sInstance;        }       private String time ;       public String getTime(){          return time ;       }        @Override        public void onCreate() {            super.onCreate();              sInstance = this;              time = System.currentTimeMillis();        }}
```

Then you can just setText.\

```
TextView tx = findViewById(R.id.your_id);tx.setText(ApplicationController.getInstance.getTime());
```


---

Original Source: https://www.mindstick.com/forum/2379/fix-the-time-from-digitalclock

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
