-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.java
41 lines (33 loc) · 1.22 KB
/
Utils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Utils {
public static final String stpFormat = "| %-15s | %-11.2f | %-11.2f | %-11.2f | %-11.2f |%n";
public static final String employeeFormat = "| %-20s | %-25s | %-10s | %-10s |%n";
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
public static String string(String prompt){
System.out.print(prompt+": ");
return In.nextLine();
}
public static char choice(String prompt){
System.out.print(prompt+": ");
return In.nextChar();
}
public static double amount(String prompt){
System.out.print(prompt+": ");
return In.nextDouble();
}
public static int number(String prompt){
System.out.print(prompt+": ");
return In.nextInt();
}
public static String formattedValue(String symbol, double value){
return String.format(symbol+"%.2f", value);
}
public static String formattedDate(Date date){
return dateFormat.format(date);
}
public static Date parseDate(String date) throws ParseException{
return dateFormat.parse(date);
}
}