Every time I run the code, in the emulator and on real device i get the time of the first run. It doesn't update.
In my opinion, every time that I run the code I should get the system time displayed and printed in the Log. This doesn't happen.
I'm new to android ... a help can be useful.
I know they are static, the c is formed by using getInstance() instead of new (). Variables should get the values when they're initialized as a first thing.
A new instance of class is created when I start the application with the emulator.
I've changed, i put c.get and still nothing.... same values.
Has anyone have an answer?
Tim Moores wrote:This has nothing to do with Android, it's basic Java. "c.YEAR" is not an accessor method to retrieve the current year from c, it's a static (i.e., unchanging) number that means something entirely different. What you meant to do is c.get(Calendar.YEAR).
no change, replaced with c.get(Calendar.YEAR) and no change, I get the same time value.
Date and Calendar are different class that provide different methods in each other. Better to you, will be using GregorianCalendar class, the class is not abstract like Calendar class, but is a subclass of Calendar.
GregorianCalendar object has many different methods to manipulate the date, time. You can format the myCalendar object in the same style as Date object, by SimpleDateFormat object.
Try to make in pure Java, a few examples, using GregorianCalendar class.
Bye. Sorry for my english, I'm still learning.