File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,21 @@ public class BasicDuration extends AbstractScalar implements Comparable<BasicDur
14
14
15
15
public BasicDuration (DURATION unit , int value ){
16
16
this .value = value ;
17
+ if (unit == DURATION .TDAY )
18
+ throw new RuntimeException ("the exchange unit should be given when use exchange calendar." );
17
19
this .unit = unit ;
18
20
this .exchange_ = unit .ordinal ();
19
21
}
20
22
23
+ public BasicDuration (DURATION unit , int value , String exchangeUnit ) {
24
+ this .value = value ;
25
+ this .unit = unit ;
26
+ if (this .unit == DURATION .TDAY )
27
+ this .exchange_ = getCodeNumber (exchangeUnit );
28
+ else
29
+ this .exchange_ = this .unit .ordinal ();
30
+ }
31
+
21
32
public BasicDuration (String unit , int value ) {
22
33
this .value = value ;
23
34
int codeNumber = getCodeNumber (unit );
@@ -179,6 +190,8 @@ private int getCodeNumber(String unit) {
179
190
} else if (unit .length () == 4 ) {
180
191
int [] codes = new int [4 ];
181
192
for (int i = 0 ; i < 4 ; i ++) {
193
+ if (Character .isLowerCase (unit .charAt (i )))
194
+ throw new RuntimeException ("the exchange unit except all upper, got " + unit );
182
195
codes [i ] = unit .charAt (i );
183
196
}
184
197
return (codes [0 ] << 24 ) + (codes [1 ] << 16 ) + (codes [2 ] << 8 ) + codes [3 ];
You can’t perform that action at this time.
0 commit comments