Skip to content

Commit 00ced75

Browse files
committed
feat(datetime-api): add DateDemo2 demonstrating epoch time and Long.MAX_VALUE
What - Added DateDemo2 class to demonstrate working with epoch-based time in Java. - Shows: - System.currentTimeMillis() → milliseconds since 1st Jan 1970 (Unix epoch). - Long.MAX_VALUE → maximum value storable in a long, useful for understanding limits of time representation. Why - Introduces the concept of epoch time, the foundation for most date/time APIs and system clocks. - Helps developers understand how Java internally represents dates and times. - Provides context on range limitations when storing time values in long. How to use - Run DateDemo2. - Output will display: 1. Current epoch time in milliseconds. 2. Long.MAX_VALUE, showing the upper bound of long type. Real-life applications - Epoch time is widely used in: - Logging frameworks (timestamps). - Databases (storing created_at/updated_at fields). - Distributed systems (event ordering, synchronization). - Scheduling jobs relative to current system time. - Long.MAX_VALUE awareness helps when working with time calculations, avoiding overflow errors. Notes - Epoch time in Java is always measured from 1st Jan 1970 UTC. - System.currentTimeMillis() is affected by system clock changes; for monotonic time use System.nanoTime(). - Long.MAX_VALUE corresponds to approximately 292 million years in milliseconds → practically “infinite” for real-world use. Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent a362ace commit 00ced75

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
public class DateDemo {
1+
public class DateDemo2 {
22
public static void main(String[] args) {
3-
//1st January 1970 se Ab tak till now.
43
System.out.println(System.currentTimeMillis());
54
System.out.println(Long.MAX_VALUE);
65
}
7-
}
6+
}

0 commit comments

Comments
 (0)