Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
Add Comment
Please, Sign In to add comment