Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 71
Java Jpanels and Jframe 8 28
VB Script to add site to Java Exception List 4 47
rhino JavaScript import, load 25 66
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

948 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

24 Experts available now in Live!

Get 1:1 Help Now