Write a program in Java that converts date formats from American Format: “September 5, 2019” to International Format; - such as “2019-September-5”.
import java.util.Scanner; public class ConvertDateFormats { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter date in American Format(Ex: September 5, 2019): "); String date = in.nextLine(); String[] words = date.split(" "); String internationalFormatDate = words[2] + "-" + words[0] + "-" + words[1].substring(0, words[1].length()-1); System.out.println(internationalFormatDate); } }
Get Answers For Free
Most questions answered within 1 hours.