Solved

Date problem... I am looking for today's date

Posted on 2006-11-23
4
195 Views
Last Modified: 2010-03-31
Hi Experts


I don't know how to parse an int into a date format

I have to format 20061123 into a Date so that the next while statement will work :


try{
            cal.setTime(format.parse("" + "01-Jan-80"));      
            Date endDate = ?????
            
      
            int j=0;
            
            while(cal.getTime().before(endDate)) {
                  if (j==0){
                        test[j] = "All";
                        j++;
                  }else{
                        String text = format.format(cal.getTime());
                      test[j]= text;
                      cal.add(Calendar.DATE, 1);
                      j++;
                        }
                  }
            }catch(ParseException exp){
          }
0
Comment
Question by:blarouche
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 18005141
Date endDate = new SimpleDataFormat("yyyyMMdd").parse(Integer.toString(20061123));
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18005144
SimpleDataFormat=SimpleDateFormat
0
 

Author Comment

by:blarouche
ID: 18005207
You're fantastic !!!


thank you
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18005217
:-)

Integer.valueOf would be better still
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now