Solved

How to convert Java.util.Date to Calendar?

Posted on 2006-11-15
2
2,452 Views
Last Modified: 2012-06-22
Dear Experts,

I'm trying to convert a Java.util.Date to a Calendar.  Apparently, the ...Date is being deprecated in favor of Calendar.  I don't actually have the Date per se.  I have the "milliseconds since 12/1/1970" long value, which apparently forms the basis of Date.  WITHOUT USING DEPRECATED DATE METHODS, is there a way I can convert the long value directly into a Calendar?

Thanks,
BrianMc1958
0
Comment
Question by:BrianMc1958
2 Comments
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 500 total points
ID: 17949521
use this:


Calender cal = Calendar.getInstance();
cal.setTimeInMillis(...);
0
 

Author Comment

by:BrianMc1958
ID: 17949536
All right!
--BrianMc1958
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question