I am new to Java and am experimenting with the language. I am looking a way to convert a user-inputted date and convert it to the MSexcel format. So 1998/07/05 is 35981. Any clue on how to do this?
This is what I have so far
import java.util.*;
import java.text.*;
public class A1Q1
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int year;
int sv1;
int month;
int sv2;
int day;
System.out.println("Enter a time in the format yyyy/mm/dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
try
{
String userDate = input.next();
Date date = sdf.parse(userDate);
System.out.println(date);
}
catch(ParseException e)
{
e.printStackTrace();
}
}
}