I have a Date 2014-10-01 00:00:00.0 I have to convert into 10/01.2014 How can i?
            Asked
            
        
        
            Active
            
        
            Viewed 4.1k times
        
    -1
            
            
        - 
                    4Such "How can I" questions are more of "Give me the code" questions. Look at the related questions on the right. Good luck! – devnull Mar 10 '14 at 07:24
- 
                    rajesh, is your problem solved? – Nurdin Mar 10 '14 at 07:28
- 
                    Why dont You search a little for solution? Here is something what will help You: http://www.mkyong.com/java/java-date-and-calendar-examples/ – RobertoB Mar 10 '14 at 07:26
5 Answers
6
            how about this one
try
 {
    String currentDate = "2014-10-01 00:00:00.0";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    Date tempDate=simpleDateFormat.parse(currentDate);
    SimpleDateFormat outputDateFormat = new SimpleDateFormat("dd/MM.YYYY");           
    System.out.println("Output date is = "+outputDateFormat.format(tempDate));
  } catch (ParseException ex) 
  {
        System.out.println("Parse Exception");
  }
 
    
    
        Nurdin
        
- 23,382
- 43
- 130
- 308
2
            
            
        Use SimpleDateFormat:
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String date = sdf.format("Your date");
 
    
    
        Paresh Mayani
        
- 127,700
- 71
- 241
- 295
 
    
    
        Shriram
        
- 4,343
- 8
- 37
- 64
0
            
            
        try This
// Create an instance of SimpleDateFormat used for formatting 
  // the string representation of date (month/day/year)
  DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
 // Get the date today using Calendar object.
   Date today = Calendar.getInstance().getTime();        
    // Using DateFormat format method we can create a string 
  // representation of a date with the defined format.
  String reportDate = df.format(today);
   // Print what date is today!
System.out.println("Report Date: " + reportDate);
 
    
    
        Ravi Godara
        
- 497
- 6
- 20
0
            
            
        It's pretty easy if you use the JodaTime library.
    DateTime dt = new DateTime();
    DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd.YYYY");
    String str = fmt.print(dt);
 
    
    
        mtbomb
        
- 1,107
- 1
- 13
- 16
0
            
            
        try this:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date d = sdf.parse("dd/MM.YYYY");
 
    
    
        Salah
        
- 8,567
- 3
- 26
- 43
