Solved

Date question

Posted on 2004-04-19
11
274 Views
Last Modified: 2011-09-20
Hello all

anyone know of a easy way to work with this date senario:
I have the year in the format of 2004. (any year,including leap years)
i have the day in the format of 111. (any date 1-366)

I need to find out what day this is? (ie 2004, 27 would give me January 27 2004)
thanks

0
Comment
Question by:91mustang
  • 5
  • 3
  • 2
11 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10859872
Use a Calendar and set the appropriate fields
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10859884
0
 
LVL 9

Assisted Solution

by:Nick_72
Nick_72 earned 50 total points
ID: 10860006
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, 2004);
    c.set(Calendar.DAY_OF_YEAR, 27);
    System.out.println(sdf.format(c.getTime()));
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 10860072
Assuming you've got Strings as input (remove Integer.parseInt if not) this will give you your required format:


   SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy");
   Calendar c = Calendar.getInstance();
   c.set(Calendar.YEAR, Integer.parseInt("2004"));
   c.set(Calendar.DAY_OF_YEAR, Integer.parseInt("111"));
   System.out.println(sdf.format(c.getTime()));
0
 
LVL 4

Author Comment

by:91mustang
ID: 10860137
thanks :)
0
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.

 
LVL 86

Expert Comment

by:CEHJ
ID: 10860198
8-)
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10860421
You're welcome
0
 
LVL 4

Author Comment

by:91mustang
ID: 10860595
Sorry nick, I was in a rush when i looked at the anwer, and didn't notice someone other than CEHJ posted... will open a new one for ya. sorry again...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10860627
You can't do that 91mustang - it's against the rules. If you want you can ask CS to reopen this one.
0
 
LVL 4

Author Comment

by:91mustang
ID: 10860960
sorry nick, i tried, the mod will give you points on this Q
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
groupSum5 challenge 5 69
DO we need Java installed on a Windows PC and WHY ? 13 97
Spring Framework HTTPSession management 1 23
couple of eclipse 5 21
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)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

911 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

22 Experts available now in Live!

Get 1:1 Help Now