435. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/13/2018 10:35:32 AM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

435.1 Files compared

# Location File Last Modified
1 v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\util\date TimeZoneUtils.java Fri Dec 7 17:36:40 2018 UTC
2 v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\util\date TimeZoneUtils.java Wed Dec 12 19:52:48 2018 UTC

435.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 324
Changed 1 2
Inserted 0 0
Removed 0 0

435.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

435.4 Active regular expressions

No regular expressions were active.

435.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** *********
  2    * Copyrii ght 2008 V HA. All ri ghts reser ved
  3    ********* ********** ********** ********** ********** ********** *********/
  4   package go v.va.med.f w.util.dat e;
  5  
  6   import jav a.text.Par seExceptio n;
  7   import jav a.text.Sim pleDateFor mat;
  8   import jav a.util.Dat e;
  9   import jav a.util.Has hSet;
  10   import jav a.util.Set ;
  11   import jav a.util.Tim eZone;
  12  
  13   import gov .va.med.fw .util.Date Utils;
  14   import gov .va.med.fw .util.Stri ngUtils;
  15  
  16   /**
  17    * Support s TimeZone  functions /manipulat ion/conver sion
  18    * 
  19    * Sep 29,  2008
  20    * 
  21    * @author          DN S
  22    */
  23   public cla ss TimeZon eUtils {
  24           pu blic stati c final St ring TIMEZ ONE_FORMAT  = DateUti ls.MMDDYYY YHHMM_EDIT  + " zzz";
  25  
  26           pu blic stati c final St ring GMT_P REFIX = "G MT";
  27  
  28           pu blic stati c TimeZone  getGMTTim eZone(int  rawOffsetW ithoutDayl ightSaving ) {
  29                    retu rn TimeZon e.getTimeZ one(GMT_PR EFIX + raw OffsetWith outDayligh tSaving);
  30           }
  31  
  32           /* *
  33            *  Does a be st attempt  to identi fy TimeZon e. It can  not be exa ct without  the
  34            *  true Time Zone name  (eg, Ameri ca/New Yor k) due to  differing  Daylight
  35            *  Saving ti me rules t hat can be  shared wi thin the s ame GMT of fset. Give s
  36            *  higher we ight to US  TimeZones .
  37            *  
  38            *  @param ra wOffsetWit houtDaylig htSaving
  39            *  @param ob servesDayl ightSaving
  40            *  @return
  41            * /
  42           pu blic stati c TimeZone  getTimeZo ne(int raw OffsetWith outDayligh tSaving,
  43                             boolea n observes DaylightSa ving) {
  44                    Time Zone targe tTimeZone  = null;
  45                    Set< TimeZone>  matchingTi meZones =  doGetTimeZ ones(rawOf fsetWithou tDaylightS aving,
  46                                      observes DaylightSa ving);
  47                    for  (TimeZone  timeZone :  matchingT imeZones)  {
  48                             if (ta rgetTimeZo ne == null ) {
  49                                      targetTi meZone = t imeZone;
  50                             }
  51  
  52                             if (ti meZone.get ID().start sWith("US/ ")) {
  53                                      targetTi meZone = t imeZone;
  54                                      break;
  55                             }
  56                    }
  57                    retu rn targetT imeZone;
  58           }
  59  
  60           /* *
  61            *  For appli cation sta ndardizati on across  domestic t imezones,  gives high er
  62            *  weight to  "US" Time Zones over  "America"  TimeZones .
  63            *  
  64            *  @return
  65            * /
  66           pu blic stati c TimeZone  getTimeZo ne() {
  67                    Time Zone curre nt = TimeZ one.getDef ault();
  68                    retu rn getTime Zone(curre nt.getRawO ffset() /  3600000, c urrent.get DSTSavings () != 0 ?  true
  69                                      : false) ;
  70           }
  71  
  72           pu blic stati c String c onvertDate ToTimeZone (Date date , TimeZone  timeZone)  {
  73                    if ( date == nu ll)
  74                             return  StringUti ls.EMPTY;
  75  
  76                    Simp leDateForm at sdf = n ew SimpleD ateFormat( TIMEZONE_F ORMAT);
  77                    if ( timeZone ! = null)
  78                             sdf.se tTimeZone( timeZone);
  79                    retu rn sdf.for mat(date);
  80           }
  81  
  82           pu blic stati c String c onvertDate ToUTC(Date  date, boo lean inclu deTimeZone InString)  {
  83                    if ( date == nu ll)
  84                             return  StringUti ls.EMPTY;
  85  
  86                    Simp leDateForm at sdf = n ew SimpleD ateFormat( includeTim eZoneInStr ing ? TIME ZONE_FORMA T
  87                                      : DateUt ils.MMDDYY YYHHMM_EDI T);
  88                    sdf. setTimeZon e(TimeZone .getTimeZo ne(GMT_PRE FIX));
  89                    retu rn sdf.for mat(date);
  90           }
  91  
  92           pu blic stati c String c onvertDate ToTimeZone (DateWithT imeZone da te) {
  93                    if ( date == nu ll)
  94                             return  StringUti ls.EMPTY;
  95                    retu rn convert DateToTime Zone(date. getDate(),  date.getT imeZone()) ;
  96           }
  97  
  98           pr ivate stat ic Set<Tim eZone> doG etTimeZone s(int rawO ffsetWitho utDaylight Saving,
  99                             boolea n observes DaylightSa ving) {
  100                    Set< TimeZone>  targetTime Zones = ne w HashSet< TimeZone>( );
  101                    Stri ng[] match ingZones =  TimeZone. getAvailab leIDs(rawO ffsetWitho utDaylight Saving * 3 600000);
  102                    Time Zone timeZ one = null ;
  103                    for  (int i = 0 ; i < matc hingZones. length; i+ +) {
  104  
  105                             timeZo ne = TimeZ one.getTim eZone(matc hingZones[ i]);
  106                             if (ti meZone.use DaylightTi me() == ob servesDayl ightSaving ) {
  107                                      targetTi meZones.ad d(timeZone );
  108                             }
  109                    }
  110  
  111                    retu rn targetT imeZones;
  112           }
  113  
  114           /* *
  115            *  This func tion assum es input s trings are  generally  in the fo rm of
  116            *  MM/dd/yyy y HH:mm [z zz], where  zzz repre sents an o ptional Ti meZone
  117            *  
  118            *  @param st r
  119            *  @param ti meZone
  120            *  @return
  121            *  @throws P arseExcept ion
  122            * /
  123           pu blic stati c Date par seDate(Str ing str, T imeZone ti meZone) th rows Parse Exception  {
  124                    if ( StringUtil s.isEmpty( str))
  125                             return  null;
  126                    Stri ng[] token s = str.sp lit(" ");
  127                    Stri ng pattern  = TIMEZON E_FORMAT;
  128                    if ( tokens.len gth == 2)
  129                             patter n = DateUt ils.MMDDYY YYHHMM_EDI T;
  130                    retu rn DateUti ls.parseDa te(str, pa ttern, tim eZone);
  131           }
  132  
  133           pu blic stati c Date con vertUTCDat eToSpecifi edTimeZone (Date date , TimeZone  tz) {
  134                    int  offset = ( tz.getOffs et(date.ge tTime()));
  135                    retu rn new Dat e(date.get Time() + o ffset);
  136           }
  137  
  138           pu blic stati c Date con vertCurren tDateToSpe cifiedTime Zone(TimeZ one tz) {
  139                    Date  curDate =  new Date( );
  140                    Time Zone tz1 =  TimeZone. getDefault ();
  141                    int  offset = ( tz.getOffs et(curDate .getTime() ) - tz1.ge tOffset(cu rDate.getT ime()));
  142                    retu rn new Dat e(curDate. getTime()  + offset);
  143           }
  144  
  145           /*
  146            *  ThreadLoc al used to  pass curr ent timezo n through  long stqac k of calls  and
  147            *  exceptrio ns
  148            * /
  149           pr ivate stat ic ThreadL ocal<TimeZ one> curre ntTimeZone  = new Thr eadLocal<T imeZone>() ;
  150  
  151           pu blic stati c TimeZone  getThread CurrentTim ezone() {
  152                    retu rn current TimeZone.g et();
  153           }
  154  
  155           pu blic stati c void set ThreadCurr entTimezon e(TimeZone  tz) {
  156                    curr entTimeZon e.set(tz);
  157           }
  158  
  159           pu blic stati c void rem oveThreadC urrentTime zone() {
  160                    curr entTimeZon e.remove() ;
  161           }
  162  
  163   }