how do i replace [an RTC] chip with software?
You can't. An RTC is made of basically two things:
- a carefully trimmed crystal oscillator that has a very stable and well
- some logic to count the oscillations and convert that to time and
The logic can be easily replaced by software, but the crystal cannot.
Any “pure software” solution you may find ultimately relies on counting
cycles of the system clock (the signal that clocks the whole
microcontroller). On most Arduinos, including the Uno, the system clock
is based on a ceramic resonator. These are usually specified with
0.5% frequency tolerance, and they typically have a frequency offset of
about ±0.1%. That's a drift of ±44 minutes per month!
You can get better accuracy by calibrating your Arduino's clock, and
correcting by software the frequency offset you measure. However, the
frequency is not only off, it is also quite unstable, and very sensitive
to temperature variations. So even with calibration you end up with a
clock that is ridiculously bad compared with the cheapest quartz watch.
is there a c++ library equivalent to the java library java.util.date?
I don't know Java, but there are C++ libraries available for managing
time. For example, you could initialize Paul Stoffregen's TimeLib as
setTime(hr,min,sec,day,mnth,yr); // set initial time
setSyncInterval(-1); // pretend we don't need to resync
and then periodically query the time with
now(). That should be all
you need to build a “proof of concept” of your clock: it will tell you
the time, but with an awfully bad long-term accuracy.
Note that, once you add an RTC or another good time source, you can add
a “time provider” to that library, keep the rest of your code unchanged,
and benefit from the accuracy of your new time source.
Can i run a java program instead of a c program on my arduino [...]?
No, you can't. A Java runtime will never fit in your Arduino.