아래에이 기능이 있습니다.C# -DateTime에 대한 Java 동등성은 무엇입니까?
다른 문자열로 만들어진 문자열과 키를 수신합니다.
이 함수는 inputs
을 가져 와서 날짜를 추가하여 유효성을 검사하는 데 정확히 동일한 키를 만듭니다. 이제
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;
}
, 나는 자바에서 완전한 newb 해요, 그리고 난 자바 aswell에서이 함수에 상응해야하고, 내가 자바 Date
또는 DateTime
작품, 내가 '방법에 대한 약간의 지식을 가지고 있기 때문에 누군가 코드를 적절하게 조정하는 방법을 알려줄 수 있다면 매우 행복 할 것이다.
미리 감사드립니다.
이 질문에 대한 답변은 Java 설명서에서 간단히 볼 수 있습니다. 왜 우리가 너를 위해서 그런 걸 기대하니? – Sven
@sven 나는 완전한 대답이 아니라, 포인터를 요구하고 있었다. 나는 총 대답을 기대하지 않았다. – doge
충분히 정교합니다. :) – Sven