Produced by Araxis Merge on 6/9/2017 3:49:56 PM Eastern Daylight 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:49:56 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-common\src\main\java\gov\va\nvap\common\date | DateUtil.java | Fri Apr 21 20:03:26 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 170 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 1 | package go v.va.nvap. common.dat e; | |||||
| 2 | ||||||
| 3 | import gov .va.nvap.c ommon.vali dation.Ass ert; | |||||
| 4 | import gov .va.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 5 | import jav a.text.Par seExceptio n; | |||||
| 6 | import jav a.text.Sim pleDateFor mat; | |||||
| 7 | import jav a.util.Cal endar; | |||||
| 8 | import jav a.util.Dat e; | |||||
| 9 | ||||||
| 10 | /** | |||||
| 11 | * Utility for date and time. | |||||
| 12 | * | |||||
| 13 | * @author Asha Amri traj | |||||
| 14 | */ | |||||
| 15 | public cla ss DateUti l { | |||||
| 16 | ||||||
| 17 | pu blic stati c Date dat eFromStrin g(final St ring dateS tring) { | |||||
| 18 | try { | |||||
| 19 | Assert .assertNot Empty(date String, "D ate string cannot be empty!"); | |||||
| 20 | return DateUtil. parseDateF romString( dateString ); | |||||
| 21 | } ca tch (final ParseExce ption ex) { | |||||
| 22 | throw new Runtim eException (ex); | |||||
| 23 | } | |||||
| 24 | } | |||||
| 25 | ||||||
| 26 | pu blic stati c String f ormatDatey yyyMMddHHm mssSSSZ(fi nal Date d ate) { | |||||
| 27 | if ( NullChecke r.isEmpty( date)) { | |||||
| 28 | return null; | |||||
| 29 | } | |||||
| 30 | fina l SimpleDa teFormat d f = new Si mpleDateFo rmat("yyyy MMddHHmmss .SSSZ"); | |||||
| 31 | retu rn df.form at(date); | |||||
| 32 | } | |||||
| 33 | ||||||
| 34 | pu blic stati c String g etCurrentD ateTimeyyy yMMddHHmms s() { | |||||
| 35 | fina l SimpleDa teFormat d f = new Si mpleDateFo rmat("yyyy MMddHHmmss "); | |||||
| 36 | retu rn df.form at(Calenda r.getInsta nce().getT ime()); | |||||
| 37 | } | |||||
| 38 | ||||||
| 39 | /* * | |||||
| 40 | * Returns a TimeStamp for the c urrent tim e on the s erver. Thi s can be | |||||
| 41 | * useful fo r a client which res ides in an other time zone or wh ich has | |||||
| 42 | * questiona ble date/t ime settin gs (like a PC). A cl ient can b ase a quer y on | |||||
| 43 | * the serve rs time ra ther than the client s time. | |||||
| 44 | * <p> | |||||
| 45 | * The time format is: YYYYMMDDH HMMSS.SSS, with a ti mezone on the end. T he | |||||
| 46 | * timezone is + or - ZZZZ(HHMM) from GMT or just Z for GMT. | |||||
| 47 | * | |||||
| 48 | * @return S tring - Th e time. | |||||
| 49 | * @since jd k1.2 | |||||
| 50 | * / | |||||
| 51 | pu blic stati c String g etCurrentT ime() { | |||||
| 52 | fina l SimpleDa teFormat d f = new Si mpleDateFo rmat("yyyy MMddHHmmss .SSSZ"); | |||||
| 53 | retu rn df.form at(Calenda r.getInsta nce().getT ime()); | |||||
| 54 | } | |||||
| 55 | ||||||
| 56 | pu blic stati c Date get RecentDate (final Dat e... dates ) { | |||||
| 57 | if ( NullChecke r.isEmpty( dates)) { | |||||
| 58 | return null; | |||||
| 59 | } | |||||
| 60 | Date recent = dates[0]; | |||||
| 61 | for (final Dat e date : d ates) { | |||||
| 62 | if (re cent.befor e(date)) { | |||||
| 63 | recent = date; | |||||
| 64 | } | |||||
| 65 | } | |||||
| 66 | retu rn recent; | |||||
| 67 | } | |||||
| 68 | ||||||
| 69 | /* * | |||||
| 70 | * Attempts to parse a date form atted stri ng. TODO: Not a good way to pa rse | |||||
| 71 | * a date by exception s. Refacto r code! NO TE: Parse formats sh ould be in | |||||
| 72 | * length or der. | |||||
| 73 | * | |||||
| 74 | * @param s | |||||
| 75 | * a date f ormatted s tring, 1 o f 6 format s | |||||
| 76 | * @return D ate - the date | |||||
| 77 | * @throws P arseExcept ion | |||||
| 78 | * excepti on from pa rsing the string TOD O: Refacto r method!! | |||||
| 79 | * / | |||||
| 80 | pu blic stati c Date par seDateFrom String(fin al String s) | |||||
| 81 | throws ParseExce ption { | |||||
| 82 | ||||||
| 83 | if ( NullChecke r.isEmpty( s)) { | |||||
| 84 | return null; | |||||
| 85 | } | |||||
| 86 | Date date = nu ll; | |||||
| 87 | Simp leDateForm at ofd = n ull; | |||||
| 88 | ||||||
| 89 | try { | |||||
| 90 | ofd = new Simple DateFormat ("yyyyMMdd hhmmssZ"); | |||||
| 91 | date = ofd.parse (s); | |||||
| 92 | return date; | |||||
| 93 | } ca tch (final ParseExce ption ex) { | |||||
| 94 | } | |||||
| 95 | ||||||
| 96 | try { | |||||
| 97 | ofd = new Simple DateFormat ("MM/dd/yy yy hh:mm:s s aa"); | |||||
| 98 | date = ofd.parse (s); | |||||
| 99 | return date; | |||||
| 100 | } ca tch (final ParseExce ption ex) { | |||||
| 101 | } | |||||
| 102 | ||||||
| 103 | // a dded parse r to handl e date for mat of MMM dd, yyyy@ hh:mm:ss | |||||
| 104 | try { | |||||
| 105 | ofd = new Simple DateFormat ("MMM dd, yyyy@hh:mm :ss"); | |||||
| 106 | date = ofd.parse (s); | |||||
| 107 | return date; | |||||
| 108 | } ca tch (final ParseExce ption ex) { | |||||
| 109 | } | |||||
| 110 | ||||||
| 111 | if ( NullChecke r.isEmpty( date)) { | |||||
| 112 | try { | |||||
| 113 | ofd = ne w SimpleDa teFormat(" MMM dd, yy yy"); | |||||
| 114 | date = o fd.parse(s ); | |||||
| 115 | return d ate; | |||||
| 116 | } catc h (final P arseExcept ion ex) { | |||||
| 117 | } | |||||
| 118 | } | |||||
| 119 | if ( NullChecke r.isEmpty( date)) { | |||||
| 120 | try { | |||||
| 121 | ofd = ne w SimpleDa teFormat(" MMM dd,yyy y"); | |||||
| 122 | date = o fd.parse(s ); | |||||
| 123 | return d ate; | |||||
| 124 | } catc h (final P arseExcept ion ex) { | |||||
| 125 | } | |||||
| 126 | } | |||||
| 127 | if ( NullChecke r.isEmpty( date)) { | |||||
| 128 | try { | |||||
| 129 | ofd = ne w SimpleDa teFormat(" MM/dd/yyyy "); | |||||
| 130 | date = o fd.parse(s ); | |||||
| 131 | return d ate; | |||||
| 132 | } catc h (final P arseExcept ion ex) { | |||||
| 133 | } | |||||
| 134 | } | |||||
| 135 | if ( NullChecke r.isEmpty( date)) { | |||||
| 136 | try { | |||||
| 137 | ofd = ne w SimpleDa teFormat(" MM/dd/yy") ; | |||||
| 138 | date = o fd.parse(s ); | |||||
| 139 | return d ate; | |||||
| 140 | } catc h (final P arseExcept ion ex) { | |||||
| 141 | } | |||||
| 142 | } | |||||
| 143 | if ( NullChecke r.isEmpty( date)) { | |||||
| 144 | String tempS = s ; | |||||
| 145 | if (te mpS.length () > 8) { | |||||
| 146 | tempS = tempS.subs tring(0, 8 ); | |||||
| 147 | } | |||||
| 148 | ofd = new Simple DateFormat ("yyyyMMdd "); | |||||
| 149 | date = ofd.parse (tempS); | |||||
| 150 | } | |||||
| 151 | retu rn date; | |||||
| 152 | } | |||||
| 153 | ||||||
| 154 | /* * | |||||
| 155 | * Default c onstructor . | |||||
| 156 | * / | |||||
| 157 | pr otected Da teUtil() { | |||||
| 158 | } | |||||
| 159 | ||||||
| 160 | public static Da te voidTim e(final Da te date) { | |||||
| 161 | fina l Calendar cal = Cal endar.getI nstance(); | |||||
| 162 | cal. setTime(da te); | |||||
| 163 | cal. set(Calend ar.HOUR_OF _DAY, 0); | |||||
| 164 | cal. set(Calend ar.MINUTE, 0); | |||||
| 165 | cal. set(Calend ar.SECOND, 0); | |||||
| 166 | cal. set(Calend ar.MILLISE COND, 0); | |||||
| 167 | retu rn cal.get Time(); | |||||
| 168 | } | |||||
| 169 | ||||||
| 170 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.