int k = year % 7; // The year of the century
You might want % 100
there.
Also, you’re mixing two of the formulae. If you’re after the best implementation in software (as provided by Wikipedia), try this:
// ... // remove j and k int y = year; // ... // reformatted for readability int h = (q + (int)((26 * (m + 1)) / 10.0) + y + (int)(y / 4.0) + // changes after here 6 * (int)(y / 100.0) + (int)(y / 400.0)) % 7;
or this:
int h = (q + (int)((13 * (m + 1)) / 5.0) + k + (int)(k / 4.0) // ^^ + (int)(j / 4.0) + (5 * j)) % 7;
You were (likely inadvertently) using the start of the second software formula with the end of the first one, causing the computer no end of confusion.
Related Posts:
- Unable to find valid certification path to requested target – error even after cert imported
- Java – Convert integer to string [duplicate]
- How does System.out.print() work?
- Initialize part of an array in java
- What is the proper way to handle a NumberFormatException when it is expected?
- What causes “Unable to access jarfile” error?
- Where is JRE 11? [duplicate]
- How to convert/parse from String to char in java?
- How to set a Timer in Java?
- How to parse JSON in Java
- Can’t execute jar- file: “no main manifest attribute”
- What is the difference between a static method and a non-static method?
- Is there a method that calculates a factorial in Java?
- What is Java Servlet?
- Generating a Random Number between 1 and 10 Java
- Generating a Random Number between 1 and 10 Java [duplicate]
- How do I generate random integers within a specific range in Java?
- Best way to convert an ArrayList to a string
- Does a Java to C++ converter/tool exist?
- How change the color arrowIcon to JMenu when it is selected
- javac : command not found
- Java says FileNotFoundException but file exists
- Why am I getting InputMismatchException?
- Java integer list
- How can I properly compare two Integers in Java?
- element not interactable exception in selenium web automation
- How do I save a String to a text file using Java?
- method in class cannot be applied to given types
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- “NoClassDefFoundError: Could not initialize class” error
- Implements vs extends: When to use? What’s the difference?
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- java.util.NoSuchElementException: No line found
- How to check whether a int is not null or empty?
- How to parse JSON in Java
- Declaring an unsigned int in Java
- Converting Hexadecimal String to Decimal Integer
- LocalDate to java.util.Date and vice versa simplest conversion?
- What is a Question Mark “?” and Colon “:” Operator Used for?
- How to remove single character from a String
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- Uri not Absolute exception getting while calling Restful Webservice
- Very Basic Java
- SQLRecoverableException: I/O Exception: Connection reset
- What exactly is a Maven Snapshot and why do we need it?
- How to check if my string is equal to null?
- what is Ljava.lang.String;@
- “Could not find Java SE Runtime Environment.” after installing Java
- How can I create an utility class?
- difference between ‘static int’ and ‘int’ in java
- How to use PrintWriter and File classes in Java?
- Error message “unreported exception java.io.IOException; must be caught or declared to be thrown”
- cannot make a static reference to the non-static field
- Double cannot be dereferenced?
- Encrypt Password in Configuration Files?
- How to convert a byte array to a hex string in Java?
- How to get the last value of an ArrayList
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- How to check if the value is integer in java?
- Java Error: Invalid top level statement
- How to make an array of arrays in Java
- Instantiating object of type parameter
- Syntax error on token(s), misplaced construct(s)
- JAVA Variable declaration not allowed here
- How to check if object is null or not except == null
- how to make jni.h be found?
- difference between System.out.println() and System.err.println()
- Selenium — How to wait until page is completely loaded
- Cannot resolve symbol ‘button’ -Android Studio
- Checking to see if array is full
- Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
- “The import org.springframework cannot be resolved.”
- How to synchronize or lock upon variables in Java?
- why f is placed after float values?
- Syntax error on token “;”, { expected after this token in Random string creator
- Chrome Error: You are using an unsupported command-line flag: –ignore-certifcate-errors. Stability and security will suffer
- Printing char arrays in Java
- How to change already compiled .class file without decompile?
- Java: How To Call Non Static Method From Main Method?
- What does idempotent method mean and what are the side effects in case of calling close method of java.lang.AutoCloseable?
- Any shortcut to initialize all array elements to zero?
- Simple HTTP server in Java using only Java SE API
- make a JLabel wrap it’s text by setting a max width
- incompatible types: void cannot be converted to int [duplicate]
- Long cannot be dereferenced
- Align printf output in Java
- How do you create a REST client for Java?
- Calculate Average Java
- How to write logs in text file when using java.util.logging.Logger
- Java Memcached Client
- How to enable the Java keyword assert in Eclipse program-wise?
- Map of maps – how to keep the inner maps as maps?
- method does not override or implement a method from a supertype – for Override
- Hibernate show real SQL
- How can I set size of a button?
- Error message ‘Cannot be resolved or is not a field’
- SQL Developer with JDK (64 bit) cannot find JVM
- return an ArrayList method
- What does hasNext() in a While do?
- How can I catch all the exceptions that will be thrown through reading and writing a file?