Skip to Content
avatar image
Former Member

want to change date format

hi Experts,

i need to change date formate from DD/mm/yy to dd.mm.yy can you tel me how can it be done.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 13, 2011 at 04:32 AM

    Hi,

    Use SimpleDateFormat to achieve this..

    Regards,

    Vijay.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Try the below code...

      java.sql.Date sysDate = null; 
      String strSysDate = null;	
      sysDate = new java.sql.Date(Calendar.getInstance().getTime().getTime());
      
      Calendar cal = Calendar.getInstance();
      cal.setTime(sysDate);
      int date = cal.get(Calendar.DATE);
      int month = cal.get(Calendar.MONTH)+1;
      int year = cal.get(Calendar.YEAR);
      
      strSysDate = date+"."+month+"."+year;

      Tweeking this can help you get your desired result..

      Regards,

      Vijay.

  • avatar image
    Former Member
    Oct 13, 2011 at 10:44 AM

    Hi,

    I hope this following example will help you

    public class DateFormat

    {

    public static void main(String[] args)

    {

    try {

    // e.g dd/MM/yy = 13/10/11

    SimpleDateFormat fromDateFormat = new SimpleDateFormat("dd/MM/yy");

    SimpleDateFormat toDateFormat = new SimpleDateFormat("dd.MM.yy");

    Date date = fromDateFormat.parse("13/10/11");

    String str = toDateFormat.format(date);

    System.out.println(str);

    } catch (ParseException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    }

    }

    Thanks

    Gautam Singh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 14, 2011 at 10:35 AM

    Hello Prajakta,

    You can do it following below simple steps. First create a simple data type of type date in Local Dictionary of your webdynpro application. Then go to the Representation tab of the data type and change the Format to desired format(like dd.MM.yyyy). Then create a context attribute and set the type of this attribute to the simple data type you created before. Now you can assign this context attribute to your UI element(Input field) , run and test the application, value display format will be dd.MM.yyyy

    Thanks

    Shankha

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 17, 2011 at 10:21 AM

    Hi Shankha,

    I had also the same problem.. and the solution provided by u was done by me.... bt my problem was not solved... please help....

    Thanks ,

    Sweta

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Sweta,

      I think I am not clear with the exact requirement. Could you please create a new thread in the forum with detailing your requirement. Then other can also suggest you.

      Thanks

      Shankha