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

x
?
Solved

Calendar Object to date...

Posted on 2006-03-28
6
Medium Priority
?
283 Views
Last Modified: 2011-10-03
How do i conver a calender object to date....


i.e <%

                Calendar fromTime = Calendar.getInstance();

                fromTime.set(2006, 03, 28, 9, 0, 0);
                        
                        System.out.println(fromTime);

                     Calendar toTime = Calendar.getInstance();

                toTime.set(2006, 04, 04, 0, 0, 0);%>


i'm passing fromTime and toTime to another jsp.....there i need to retrieve the objects into date-time formats

thank you.
0
Comment
Question by:jagadeesh_motamarri
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16314122
Date d = cal.getTime();
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16314130
Use SimpleDateFormat to specify the exact parts and their format you need.

;JOOP!
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 1000 total points
ID: 16314155
Like:
    SimpleDateFormat dayFormatter = new SimpleDateFormat("dd/MM/yyyy");
      Calendar c = Calendar.getInstance();
      c.set(2004,0,28);
      System.out.println(dayFormatter.format(c.getTime()));

;JOOP!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 16314279
>>i'm passing fromTime and toTime

Pass the value as a Date- more efficient and extensible
0
 
LVL 9

Expert Comment

by:Manikandan Thiagarajan
ID: 16316887
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16348470
(:>}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

572 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