Problem converting date format in Java

后端 未结 6 1799
余生分开走
余生分开走 2021-01-21 11:58

I have a string in the form MMM/dd/yyyy, ie. May/21/2010. Now I want to convert it to yyyyMMdd, ie. 20100521.

My code is:

public static void main(String[         


        
6条回答
  •  猫巷女王i
    2021-01-21 12:17

    SimpleDateFormat uses your locale - so your computer is probably set to use Danish by default. Specify the English Locale explicitly:

    DateFormat formatter = new SimpleDateFormat("MMM", Locale.ENGLISH);
    

提交回复
热议问题