Solved

getDayOfMonth() issue

Posted on 2007-12-06
2
261 Views
Last Modified: 2013-11-23
Experts,

I need a date in the format yyyyMMdd using the following:
String valDate_yyyyMMdd = ""+valuationDate.getYear()+""+valuationDate.getMonth()+""+valuationDate.getDayOfMonth()
but it returns 2007127 instead of 20071207

Please help!

Thanks,
Margin_Walker
0
Comment
Question by:Margin_Walker
2 Comments
 
LVL 20

Accepted Solution

by:
gatorvip earned 30 total points
ID: 20420383
Why not use SimpleDateFormat?

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String result = sdf.format(  your_date );
0
 
LVL 23

Expert Comment

by:cmalakar
ID: 20420423
Here is the sample code

import java.text.*;
import java.util.*;

public class Test
{
  public static void main(String args[]) throws Exception
  {
    DateFormat df = new SimpleDateFormat("yyyyMMdd");;
    Date date1 = new Date(2007-1900, 12-1, 7);
    System.out.println(df.format(date1));
  }
}
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

707 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

18 Experts available now in Live!

Get 1:1 Help Now