Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
data
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.util.Scanner; import java.util.Date; import java.util.Calendar; import java.text.SimpleDateFormat; import java.text.ParseException; class Rextester { public static String getDay(String day, String month, String year) { String answer = ""; try{ String fullDate = year+"/"+month+"/"+day; GregorianCalendar gc = new GregorianCalendar(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date dt = df.parse(fullDate); System.out.println (dt); gc.setTime(dt); int index = gc.get( Calendar.DAY_OF_WEEK ) ; answer = String.toString(index); } catch ( ParseException prsE ) { prsE.printStackTrace(); } return answer; } public static void main(String args[]) { Scanner in = new Scanner(System.in); String month = in.next(); String day = in.next(); String year = in.next(); System.out.println(getDay(day, month, year)); } }
run
|
edit
|
history
|
help
0
Bbs
1.5
stringkeyvalues
Happy Numbers in Java
ElaineBrown**
Basic LinkedList in Java
classwork
hellojava.java
classwork
Increment Operator