I have this function below.
It recieves a string and a key made out of another string.
The function takes the inputs and adds on the date to make the exact same key to validate.
public bool isSecureKeyCorrect(string inputs,string thatKey) { DateTime now = DateTime.UtcNow.AddHours(2); string currentDateString = (now.ToString("yyyyMMddHH")); string year= currentDateString.Substring(0, 4); string month = currentDateString.Substring(4, 2); string day = currentDateString.Substring(6, 2); string hour = currentDateString.Substring(8, 2); string thisKey; thisKey = inputs.Substring(0, 2) + month+ hour + inputs.Substring(inputs.Length - 2, 2) + year + day; if (thisKey == thatKey) { return true; } else return false; } Now, since i'm a complete newb at java, and i need to make an equivalent to this function in java aswell, and i have very little knowledge about how Date or DateTime works in java, i'll be very happy if someone could give me some pointers how to properly adjust the code.
Thanks in advance.