Date
Date from specific time
This is an example of how to get aDate from a specific time. The class Date represents a specific instant in time, with millisecond precision. Getting a Date from a specific long time implies that you should:
- Create a newDate object, using the
Date(long date)constructor, with a long parameter. The constructor allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as “the epoch”, namely January 1, 1970, 00:00:00 GMT.
We can print the date to check its value.
Let’s take a look at the code snippet that follows:
package com.javacodegeeks.snippets.core;import java.util.Date;public class DateFromSpecificTime { public static void main(String[] args) { //date after (random) years, months, days, ... Date date = new Date(124840L * 13L * 12L * 48L * 1000L); System.out.println(date); }}Output:
Mon Aug 16 14:12:00 EEST 1999
This was an example of how to get a Date from a specific time in Java.
Do you want to know how to develop your skillset to become aJava Rockstar?
Subscribe to our newsletter to start Rockingright now!
To get you started we give you our best selling eBooks forFREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to theTerms andPrivacy Policy

Thank you!
We will contact you soon.
Byron Kiourtzoglou
Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor atJava Code Geeks.



