import java.util.*;
import java.io.*;
public String recToString (boolean format) {
Date date = new Date();
File inputFile = new File ("records.txt");
Scanner sc = new Scanner(inputFile);
if (format == true){
format = Date1.usFormat();
format = Date1.usFormat();
} else {
format = Date1.euFormat();
}
}
I plan to call the usFormat and euFormat.
import java.util.*;
import java.io.*;
class Date1 {
String month = "";
String day = "";
String year = "";
public Date1 (String date) {
StringTokenizer st = new StringTokenizer(date, "/");
month = st.nextToken();
day = st.nextToken();
year = st.nextToken();
} //end constructor
public String usFormat () {
String date = month + "/" + day + "/" + year;
return date;
} //end usFormat
public String euFormat () {
String date = day + "/" + month + "/" + year;
return date;
} //end euFormat
} //end class
Try to ignore any other mistakes please. But if it screws up this and I have to change it to get it, please do tell 🙂
Thanks.
You need to construct a
Date1object and call the methods on that. You need to do something like