0

I looked intensively on google, and here to find good code that works to show current date i've been through a few of the suggested questions, but they don't work to show the CURRENT date for the day the app runs. As well as I am doing the same for the current time. My goal is to basically be able to by tapping a textview of either DATE, or TIME, the user can then change the time to reflect what they choose. Then return that date/time chosen and return it to reflect in the textview.

The part I need help with is getting the current actual date of the app being opened, as well as the time separately.

Here is my code....

    Date curDate = new Date();
    SimpleDateFormat format = new SimpleDateFormat("EE, MM DD, yyyy");
    String DateToStr = format.format(curDate);

Trying to get the output string to show in a textview which does work. I want to show the short hand of both Day of the week, and the month. I am thinking I might need a locale, but I am just not familiar with this.

Would appreciate some up to date code. Or even a tutorial that is up to date that I can follow. I believe i can figure out how to get the picker data after the user selects their date/time, but I am just having a hard time showing the picker when the user selects the textview. I can show it via OnClickListener but I tried Google's example of pickers and that didn't work. My code still came up with errors for the getSupportFragmentManger(). I am doing all of this code in a Fragment, Activity. NOT to be mistaken for a FRAGMENTACTIVITY.

wesley franks
  • 6,765
  • 4
  • 16
  • 29

1 Answers1

0

I have found the answer to why my date was showing one day before. Although it isn't a complete answer it's a good troubleshooting step for those that have ran into the same problem.

Basically when using a virtual device. It doesn't show the accurate date for some reason. Make sure to be using an actual device to test on. The time will show properly.

Go --> HERE, to find a good one line coded answer by @Patrik

However, I still need assistance working on the time/date pickers, and returning the user's response in a string that is set to the textview. If anyone can help with that, that would be great. I will be posting a separate question regarding that specifically different issue. Thanks!

Community
  • 1
  • 1
wesley franks
  • 6,765
  • 4
  • 16
  • 29