Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

DateTool.java

Go to the documentation of this file.
00001 package net.threebit.utils.sosc;
00002 
00003 /*
00004         Copyright 2003 Shawn Deleurme
00005         Copyright 2003 Kevin O'Donnell
00006 
00007         This program is free software; you can redistribute it and/or modify
00008         it under the terms of the GNU General Public License as published by
00009         the Free Software Foundation; either version 2 of the License, or
00010         (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016 
00017         You should have received a copy of the GNU General Public License
00018         along with this program; if not, write to the Free Software
00019         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 */
00021 
00022 import java.io.*;
00023 import java.util.*;
00024 
00029 public class DateTool {
00030 
00034         public static String ymd() {
00035                 return ymd(System.currentTimeMillis());
00036         }
00037 
00041         public static String ymd (long date) {
00042                 StringBuffer ymd = new StringBuffer(10);
00043                 int[] a = ymdArray(date);
00044 
00045                 ymd.append(a[0]);
00046                 ymd.append("/");
00047 
00048                 if (a[1] < 10) {ymd.append("0"); }
00049                 ymd.append(a[1]);
00050                 ymd.append("/");
00051 
00052                 if (a[2] < 10) { ymd.append("0"); }
00053                 ymd.append(a[2]);
00054 
00055                 return ymd.toString();
00056         }
00057 
00061         public static int[] ymdArray () {
00062                 return ymdArray( System.currentTimeMillis() );
00063         }
00064 
00068         public static int[] ymdArray (long date) {
00069                 Calendar c = Calendar.getInstance();
00070                 c.setTimeInMillis(date);
00071                 return new int[] {
00072                         c.get(c.YEAR),
00073                         c.get(c.MONTH)+1,
00074                         c.get(c.DAY_OF_MONTH)
00075                 };
00076         }
00077 
00078 }

Generated on Mon Jul 14 17:19:20 2003 for SOSC by doxygen1.2.15