Link to home
Start Free TrialLog in
Avatar of Margin_Walker
Margin_Walker

asked on

getDayOfMonth() issue

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
ASKER CERTIFIED SOLUTION
Avatar of gatorvip
gatorvip
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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));
  }
}