Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

UtilDate.java

Go to the documentation of this file.
00001 //  -*- Java -*-
00002 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00010 
00012 package pkgUtil;
00013 
00014 import java.util.*;
00015 import java.text.*;
00016 import pkgMcj.*;
00017 
00019 public class UtilDate {
00020 
00021    private Mcj mcj;
00022 
00023    private SimpleDateFormat 
00024       strYear = new SimpleDateFormat ("yyyy.MM.dd");
00025 
00026    private SimpleDateFormat 
00027       strMonth = new SimpleDateFormat ("MM-dd hh:mm");
00028 
00029    private SimpleDateFormat 
00030       testYear = new SimpleDateFormat ("yyyy");
00031    
00032 
00033    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00037    public UtilDate( Mcj parent){
00038       mcj = parent;
00039    }
00040    
00041    
00042    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00043    public String getDateString( long value ){
00044       Date objDate = new Date(value); // the object date
00045       Date now = new Date();    // current date
00046       String nowYear = testYear.format(now); // get the current year
00047       String objYear = testYear.format(objDate); // object year
00048 
00049       if( objYear.equals( nowYear.substring(0,4) )){
00050          return strMonth.format(objDate);
00051       }
00052       return strYear.format(objDate);
00053 
00054    }   
00055    
00056 }  // UtilDate.java
00057 

SourceForge.net Logo