Going from MM/DD/YYYY to DD-MMM-YYYY in java










8














Is there a method in Java that I can use to convert MM/DD/YYYY to DD-MMM-YYYY?



For example: 05/01/1999 to 01-MAY-99



Thanks!










share|improve this question























  • Note that your pattern syntax is in fact invalid. It's y for years and d for day of month. The Y has no meaning and D is day of year. You want to convert from MM/dd/yyyy to dd-MMM-yyyy.
    – BalusC
    Nov 12 '10 at 22:33











  • Thanks. Being new to Java, it is very helpful to have things like that pointed out to me.
    – javan_novice
    Nov 13 '10 at 15:52










  • You should have the Locale.English at the options:stackoverflow.com/a/2603676/2114308
    – Phuong
    Jan 29 '16 at 4:42
















8














Is there a method in Java that I can use to convert MM/DD/YYYY to DD-MMM-YYYY?



For example: 05/01/1999 to 01-MAY-99



Thanks!










share|improve this question























  • Note that your pattern syntax is in fact invalid. It's y for years and d for day of month. The Y has no meaning and D is day of year. You want to convert from MM/dd/yyyy to dd-MMM-yyyy.
    – BalusC
    Nov 12 '10 at 22:33











  • Thanks. Being new to Java, it is very helpful to have things like that pointed out to me.
    – javan_novice
    Nov 13 '10 at 15:52










  • You should have the Locale.English at the options:stackoverflow.com/a/2603676/2114308
    – Phuong
    Jan 29 '16 at 4:42














8












8








8


3





Is there a method in Java that I can use to convert MM/DD/YYYY to DD-MMM-YYYY?



For example: 05/01/1999 to 01-MAY-99



Thanks!










share|improve this question















Is there a method in Java that I can use to convert MM/DD/YYYY to DD-MMM-YYYY?



For example: 05/01/1999 to 01-MAY-99



Thanks!







java date-format






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 1 '17 at 11:56









Blasanka

3,22541930




3,22541930










asked Nov 12 '10 at 22:27









javan_novice

44112




44112











  • Note that your pattern syntax is in fact invalid. It's y for years and d for day of month. The Y has no meaning and D is day of year. You want to convert from MM/dd/yyyy to dd-MMM-yyyy.
    – BalusC
    Nov 12 '10 at 22:33











  • Thanks. Being new to Java, it is very helpful to have things like that pointed out to me.
    – javan_novice
    Nov 13 '10 at 15:52










  • You should have the Locale.English at the options:stackoverflow.com/a/2603676/2114308
    – Phuong
    Jan 29 '16 at 4:42

















  • Note that your pattern syntax is in fact invalid. It's y for years and d for day of month. The Y has no meaning and D is day of year. You want to convert from MM/dd/yyyy to dd-MMM-yyyy.
    – BalusC
    Nov 12 '10 at 22:33











  • Thanks. Being new to Java, it is very helpful to have things like that pointed out to me.
    – javan_novice
    Nov 13 '10 at 15:52










  • You should have the Locale.English at the options:stackoverflow.com/a/2603676/2114308
    – Phuong
    Jan 29 '16 at 4:42
















Note that your pattern syntax is in fact invalid. It's y for years and d for day of month. The Y has no meaning and D is day of year. You want to convert from MM/dd/yyyy to dd-MMM-yyyy.
– BalusC
Nov 12 '10 at 22:33





Note that your pattern syntax is in fact invalid. It's y for years and d for day of month. The Y has no meaning and D is day of year. You want to convert from MM/dd/yyyy to dd-MMM-yyyy.
– BalusC
Nov 12 '10 at 22:33













Thanks. Being new to Java, it is very helpful to have things like that pointed out to me.
– javan_novice
Nov 13 '10 at 15:52




Thanks. Being new to Java, it is very helpful to have things like that pointed out to me.
– javan_novice
Nov 13 '10 at 15:52












You should have the Locale.English at the options:stackoverflow.com/a/2603676/2114308
– Phuong
Jan 29 '16 at 4:42





You should have the Locale.English at the options:stackoverflow.com/a/2603676/2114308
– Phuong
Jan 29 '16 at 4:42













6 Answers
6






active

oldest

votes


















20














Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format.



Here's some code:



 SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy");
Date date = format1.parse("05/01/1999");
System.out.println(format2.format(date));


Output:



01-May-99





share|improve this answer
















  • 2




    You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
    – BalusC
    Nov 12 '10 at 22:36











  • Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
    – Brian Clements
    Nov 12 '10 at 22:38






  • 1




    For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
    – Ole V.V.
    Nov 11 at 10:06



















2














java.time



You should use java.time classes with Java 8 and later. To use java.time, add:



import java.time.* ;


Below is an example, how you can format date.



DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MMM-yyyy");
String date = "15-Oct-2018";
LocalDate localDate = LocalDate.parse(date, formatter);

System.out.println(localDate);
System.out.println(formatter.format(localDate));





share|improve this answer






















  • @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
    – Md. Asaduzzaman
    Nov 11 at 8:35











  • Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
    – Billal Begueradj
    Nov 11 at 8:37











  • I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
    – Basil Bourque
    Nov 12 at 20:17







  • 2




    For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
    – Basil Bourque
    Nov 12 at 20:22


















1














Try this,



Date currDate = new Date();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
String strCurrDate = dateFormat.format(currDate);
System.out.println("strCurrDate->"+strCurrDate);





share|improve this answer




















  • FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
    – Basil Bourque
    Nov 12 at 20:22


















1














Try this



SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Set your date format
String currentData = sdf.format(new Date());
Toast.makeText(getApplicationContext(), ""+currentData,Toast.LENGTH_SHORT ).show();





share|improve this answer




























    0














    Below should work.



    SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
    Date oldDate = df.parse(df.format(date)); //this date is your old date object





    share|improve this answer




























      0














      formatter = new SimpleDateFormat("dd-MMM-yy");





      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4169634%2fgoing-from-mm-dd-yyyy-to-dd-mmm-yyyy-in-java%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        20














        Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format.



        Here's some code:



         SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
        SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy");
        Date date = format1.parse("05/01/1999");
        System.out.println(format2.format(date));


        Output:



        01-May-99





        share|improve this answer
















        • 2




          You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
          – BalusC
          Nov 12 '10 at 22:36











        • Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
          – Brian Clements
          Nov 12 '10 at 22:38






        • 1




          For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
          – Ole V.V.
          Nov 11 at 10:06
















        20














        Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format.



        Here's some code:



         SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
        SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy");
        Date date = format1.parse("05/01/1999");
        System.out.println(format2.format(date));


        Output:



        01-May-99





        share|improve this answer
















        • 2




          You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
          – BalusC
          Nov 12 '10 at 22:36











        • Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
          – Brian Clements
          Nov 12 '10 at 22:38






        • 1




          For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
          – Ole V.V.
          Nov 11 at 10:06














        20












        20








        20






        Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format.



        Here's some code:



         SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
        SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy");
        Date date = format1.parse("05/01/1999");
        System.out.println(format2.format(date));


        Output:



        01-May-99





        share|improve this answer












        Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format.



        Here's some code:



         SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
        SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy");
        Date date = format1.parse("05/01/1999");
        System.out.println(format2.format(date));


        Output:



        01-May-99






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 '10 at 22:30









        Brian Clements

        3,1211824




        3,1211824







        • 2




          You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
          – BalusC
          Nov 12 '10 at 22:36











        • Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
          – Brian Clements
          Nov 12 '10 at 22:38






        • 1




          For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
          – Ole V.V.
          Nov 11 at 10:06













        • 2




          You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
          – BalusC
          Nov 12 '10 at 22:36











        • Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
          – Brian Clements
          Nov 12 '10 at 22:38






        • 1




          For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
          – Ole V.V.
          Nov 11 at 10:06








        2




        2




        You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
        – BalusC
        Nov 12 '10 at 22:36





        You may want to supply a Locale to the SDF constructor, else it will just take the platform default locale for month names, which may not be the one you want to use.
        – BalusC
        Nov 12 '10 at 22:36













        Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
        – Brian Clements
        Nov 12 '10 at 22:38




        Very true, you can also set the time zone with format1.setTimeZone(TimeZone.getTimeZone("GMT"));
        – Brian Clements
        Nov 12 '10 at 22:38




        1




        1




        For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
        – Ole V.V.
        Nov 11 at 10:06





        For readers coming later to this question: The SimpleDateFormat class is long outdated and notoriously troublesome. Don’t use it. Since 2014 we have so much better in java.time, the modern Java date and time API and its DateTimeFormatter. See the correct answer by Md. Asaduzzaman.
        – Ole V.V.
        Nov 11 at 10:06














        2














        java.time



        You should use java.time classes with Java 8 and later. To use java.time, add:



        import java.time.* ;


        Below is an example, how you can format date.



        DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MMM-yyyy");
        String date = "15-Oct-2018";
        LocalDate localDate = LocalDate.parse(date, formatter);

        System.out.println(localDate);
        System.out.println(formatter.format(localDate));





        share|improve this answer






















        • @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
          – Md. Asaduzzaman
          Nov 11 at 8:35











        • Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
          – Billal Begueradj
          Nov 11 at 8:37











        • I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
          – Basil Bourque
          Nov 12 at 20:17







        • 2




          For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
          – Basil Bourque
          Nov 12 at 20:22















        2














        java.time



        You should use java.time classes with Java 8 and later. To use java.time, add:



        import java.time.* ;


        Below is an example, how you can format date.



        DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MMM-yyyy");
        String date = "15-Oct-2018";
        LocalDate localDate = LocalDate.parse(date, formatter);

        System.out.println(localDate);
        System.out.println(formatter.format(localDate));





        share|improve this answer






















        • @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
          – Md. Asaduzzaman
          Nov 11 at 8:35











        • Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
          – Billal Begueradj
          Nov 11 at 8:37











        • I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
          – Basil Bourque
          Nov 12 at 20:17







        • 2




          For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
          – Basil Bourque
          Nov 12 at 20:22













        2












        2








        2






        java.time



        You should use java.time classes with Java 8 and later. To use java.time, add:



        import java.time.* ;


        Below is an example, how you can format date.



        DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MMM-yyyy");
        String date = "15-Oct-2018";
        LocalDate localDate = LocalDate.parse(date, formatter);

        System.out.println(localDate);
        System.out.println(formatter.format(localDate));





        share|improve this answer














        java.time



        You should use java.time classes with Java 8 and later. To use java.time, add:



        import java.time.* ;


        Below is an example, how you can format date.



        DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MMM-yyyy");
        String date = "15-Oct-2018";
        LocalDate localDate = LocalDate.parse(date, formatter);

        System.out.println(localDate);
        System.out.println(formatter.format(localDate));






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 12 at 20:18









        Basil Bourque

        105k25359523




        105k25359523










        answered Nov 11 at 7:24









        Md. Asaduzzaman

        473




        473











        • @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
          – Md. Asaduzzaman
          Nov 11 at 8:35











        • Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
          – Billal Begueradj
          Nov 11 at 8:37











        • I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
          – Basil Bourque
          Nov 12 at 20:17







        • 2




          For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
          – Basil Bourque
          Nov 12 at 20:22
















        • @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
          – Md. Asaduzzaman
          Nov 11 at 8:35











        • Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
          – Billal Begueradj
          Nov 11 at 8:37











        • I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
          – Basil Bourque
          Nov 12 at 20:17







        • 2




          For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
          – Basil Bourque
          Nov 12 at 20:22















        @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
        – Md. Asaduzzaman
        Nov 11 at 8:35





        @Billal, If you add import java.time.*; in code block. then you should also add class name definition. I just want to clarify the developers which package I am using
        – Md. Asaduzzaman
        Nov 11 at 8:35













        Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
        – Billal Begueradj
        Nov 11 at 8:37





        Yes, that is very right, I actually forgot to roll back my edit, sorry, thank you
        – Billal Begueradj
        Nov 11 at 8:37













        I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
        – Basil Bourque
        Nov 12 at 20:17





        I suggest always specifying explicitly the intended Locale needed for translating the name of the month. Here we would use something English related, such as Locale.CANADA or Locale.US or Locale.UK. Pass as the optional second argument to ofPattern method. The current default locale at runtime might not be English, in which case this code with this input would fail, throwing an exception.
        – Basil Bourque
        Nov 12 at 20:17





        2




        2




        For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
        – Basil Bourque
        Nov 12 at 20:22




        For Java 6 & 7, must of the java.time functionality is available in the ThreeTen-Backport project. So no need to ever use the terrible Date/Calendar/SimpleDateFormat classes.
        – Basil Bourque
        Nov 12 at 20:22











        1














        Try this,



        Date currDate = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        String strCurrDate = dateFormat.format(currDate);
        System.out.println("strCurrDate->"+strCurrDate);





        share|improve this answer




















        • FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
          – Basil Bourque
          Nov 12 at 20:22















        1














        Try this,



        Date currDate = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        String strCurrDate = dateFormat.format(currDate);
        System.out.println("strCurrDate->"+strCurrDate);





        share|improve this answer




















        • FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
          – Basil Bourque
          Nov 12 at 20:22













        1












        1








        1






        Try this,



        Date currDate = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        String strCurrDate = dateFormat.format(currDate);
        System.out.println("strCurrDate->"+strCurrDate);





        share|improve this answer












        Try this,



        Date currDate = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        String strCurrDate = dateFormat.format(currDate);
        System.out.println("strCurrDate->"+strCurrDate);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 11 '13 at 5:39









        ASIK RAJA A

        17519




        17519











        • FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
          – Basil Bourque
          Nov 12 at 20:22
















        • FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
          – Basil Bourque
          Nov 12 at 20:22















        FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
        – Basil Bourque
        Nov 12 at 20:22




        FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle.
        – Basil Bourque
        Nov 12 at 20:22











        1














        Try this



        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Set your date format
        String currentData = sdf.format(new Date());
        Toast.makeText(getApplicationContext(), ""+currentData,Toast.LENGTH_SHORT ).show();





        share|improve this answer

























          1














          Try this



          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Set your date format
          String currentData = sdf.format(new Date());
          Toast.makeText(getApplicationContext(), ""+currentData,Toast.LENGTH_SHORT ).show();





          share|improve this answer























            1












            1








            1






            Try this



            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Set your date format
            String currentData = sdf.format(new Date());
            Toast.makeText(getApplicationContext(), ""+currentData,Toast.LENGTH_SHORT ).show();





            share|improve this answer












            Try this



            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Set your date format
            String currentData = sdf.format(new Date());
            Toast.makeText(getApplicationContext(), ""+currentData,Toast.LENGTH_SHORT ).show();






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 23 '15 at 7:05









            Jatin Devani

            120214




            120214





















                0














                Below should work.



                SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
                Date oldDate = df.parse(df.format(date)); //this date is your old date object





                share|improve this answer

























                  0














                  Below should work.



                  SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
                  Date oldDate = df.parse(df.format(date)); //this date is your old date object





                  share|improve this answer























                    0












                    0








                    0






                    Below should work.



                    SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
                    Date oldDate = df.parse(df.format(date)); //this date is your old date object





                    share|improve this answer












                    Below should work.



                    SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
                    Date oldDate = df.parse(df.format(date)); //this date is your old date object






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 12 '10 at 22:37









                    CoolBeans

                    18.1k107094




                    18.1k107094





















                        0














                        formatter = new SimpleDateFormat("dd-MMM-yy");





                        share|improve this answer



























                          0














                          formatter = new SimpleDateFormat("dd-MMM-yy");





                          share|improve this answer

























                            0












                            0








                            0






                            formatter = new SimpleDateFormat("dd-MMM-yy");





                            share|improve this answer














                            formatter = new SimpleDateFormat("dd-MMM-yy");






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 18 '13 at 23:30









                            Biclops

                            1,6191738




                            1,6191738










                            answered Nov 12 '10 at 22:33









                            zod

                            7,353215698




                            7,353215698



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4169634%2fgoing-from-mm-dd-yyyy-to-dd-mmm-yyyy-in-java%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                                Syphilis

                                Darth Vader #20