Created
July 18, 2018 11:40
-
-
Save AmrAbuelhamd/62b8f9715e07aa0bea4014f6ed7c327c to your computer and use it in GitHub Desktop.
checks times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.amromohamed.studentpart; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
/** | |
* Created by amr mohamed on 4/18/2018. | |
*/ | |
public class MytimeChecker { | |
private String currentTime; | |
MytimeChecker(){ | |
//gets current time and make it the bellow format | |
Date currentTime = Calendar.getInstance().getTime(); | |
SimpleDateFormat df = new SimpleDateFormat("HH:mm"); | |
this.currentTime = df.format(currentTime); | |
} | |
//اخر وقت مسموح فيه انه يسجل غيابه lastTime | |
//لو الوقت بتاع الطالب بعد الوقت المتحدد هترجع false | |
public boolean checktimings(String lastTime) { | |
String pattern = "HH:mm"; | |
SimpleDateFormat sdf = new SimpleDateFormat(pattern); | |
try { | |
Date date1 = sdf.parse(currentTime); | |
Date date2 = sdf.parse(lastTime); | |
if(!date1.before(date2)) { | |
return true; | |
} else { | |
return false; | |
} | |
} catch (ParseException e){ | |
e.printStackTrace(); | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment