Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 747
  • Last Modified:

How to convert datetime to long value?

I wish to use the timestamp class, as the first method is deprecated, I wish to use the second one. What is the common way to convert the year, month, date, hour, minute, second, and nano to a long value?

Timestamp(int year, int month, int date, int hour, int minute, int second, int nano)
          Deprecated. instead use the constructor Timestamp(long millis)
Timestamp(long time)
          Constructs a Timestamp object using a milliseconds time value.
0
william007
Asked:
william007
  • 3
  • 2
1 Solution
 
CEHJCommented:
Use a Calendar

long time = cal.getTimeInMillis();

(set Cal first of course)
0
 
william007Author Commented:
Hi, may I know how to set the Calendar with the date information? as I can't see a direct way to do this from the calendar API.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
william007Author Commented:
Hi, I just miss it, the calendar class has a method
set(int year, int month, int date, int hourOfDay, int minute, int second)

Thanks:-)
0
 
CEHJCommented:
:-)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now