what's wrong with this code for date with month names in convert us to eu date?i can get to work with simple date. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what's wrong with this code for date with month names in convert us to eu date?i can get to work with simple date.

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String date=sc.nextLine(); String[] m={"1","2","3","4","5","6","7","8","9","10","11","12"}; String[] m1={"January","February","March","April","May","June","July","August","September","October","November","December"}; if(date.contains(" ")){ String usdate1=date.replaceAll(", ","/").replaceAll(" ","/"); String [] usdate2=usdate1.split("/"); String day=usdate2[1]; String month=usdate2[0]; String year=usdate2[2]; String eudate=day+"/"+month+"/"+year;} for(int i=0;i<=m1.length-1;i++){ String eudate1=eudate.replaceAll(m1[i],m[i]);} System.out.println(eudate1); } }

5th Nov 2021, 1:35 PM
Killiam Chances
Killiam Chances - avatar
0 Answers