Last active
February 14, 2017 07:10
-
-
Save fty4/79a9841d33005fbdb64c3941ab2beccd to your computer and use it in GitHub Desktop.
Prüfung ob Datei heute geändert wurde
This file contains 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
/** | |
* | |
* | |
* @param p_file Get File, which to check | |
* @return Returns true if it was modified, false if not | |
*/ | |
public static boolean wasModifiedToday(File p_file) | |
{ | |
// Datum abrufen | |
Date DateFile = new Date(p_file.lastModified()); | |
Date DateNow = new Date(); | |
// Datums-Formatierer | |
SimpleDateFormat formatterDay = new SimpleDateFormat("dd"); | |
SimpleDateFormat formatterMonth = new SimpleDateFormat("MM"); | |
SimpleDateFormat formatterYear = new SimpleDateFormat("yyyy"); | |
// Pruefen ob sich der Tag geaendert hat | |
int dayDiff = ( Integer.valueOf(formatterYear.format(DateNow)) - Integer.valueOf(formatterYear.format(DateFile)) ) + | |
( Integer.valueOf(formatterMonth.format(DateNow)) - Integer.valueOf(formatterMonth.format(DateFile)) ) + | |
( Integer.valueOf(formatterDay.format(DateNow)) - Integer.valueOf(formatterDay.format(DateFile)) ); | |
// Wenn dayDiff == 0 wurde die Datei heute nicht geaendert | |
return (dayDiff == 0) ? true : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment