From: Eric P. <th...@us...> - 2009-08-14 21:45:50
|
Update of /cvsroot/sandev/sand/apps/basics/src/org/sandev/basics/util In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13951 Modified Files: DateUtil.java Log Message: Added getCurrentYear utility method, and grokYear utility method. Seems worth having something that will try figure out the year from a small integer value. Not perfect, but better than nothing. Index: DateUtil.java =================================================================== RCS file: /cvsroot/sandev/sand/apps/basics/src/org/sandev/basics/util/DateUtil.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** DateUtil.java 7 Aug 2009 22:28:20 -0000 1.15 --- DateUtil.java 14 Aug 2009 21:45:37 -0000 1.16 *************** *** 484,487 **** --- 484,512 ---- + /** + * Shorthand method to retrieve the current year. + */ + public static int getCurrentYear() + { + Calendar cal=Calendar.getInstance(); + return cal.get(Calendar.YEAR); + } + + + /** + * Figure out common shorthand values to return a full year value. + * What this method does may change over time. + */ + public static int grokYear(int year) + { + if(year<100) { + if((2000+year)>getCurrentYear()) { + year=1900+year; } + else { + year=2000+year; } } + return year; + } + + //////////////////////////////////////// // UTC utilities |