Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2006-11-23
4
220 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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:
The viewer will learn how to implement Singleton Design Pattern in Java.

808 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