source: josm/trunk/src/com/drew/lang/DateUtil.java@ 14826

Last change on this file since 14826 was 10862, checked in by Don-vip, 8 years ago

update to metadata-extractor 2.9.1

  • Property svn:eol-style set to native
File size: 884 bytes
Line 
1package com.drew.lang;
2
3/**
4 * @author Drew Noakes http://drewnoakes.com
5 */
6public class DateUtil
7{
8 private static int[] _daysInMonth365 = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
9
10 public static boolean isValidDate(int year, int month, int day)
11 {
12 if (year < 1 || year > 9999 || month < 0 || month > 11)
13 return false;
14
15 int daysInMonth = _daysInMonth365[month];
16 if (month == 1)
17 {
18 boolean isLeapYear = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
19 if (isLeapYear)
20 daysInMonth++;
21 }
22
23 return day >= 1 && day <= daysInMonth;
24 }
25
26 public static boolean isValidTime(int hours, int minutes, int seconds)
27 {
28 return hours >= 0 && hours < 24
29 && minutes >= 0 && minutes < 60
30 && seconds >= 0 && seconds < 60;
31 }
32}
Note: See TracBrowser for help on using the repository browser.