TDI-32659: Tmap:the function "Talenddate"-"diffdate" is not correct
https://jira.talendforge.org/browse/TDI-32659
This commit is contained in:
@@ -8,65 +8,64 @@ package routines;
|
||||
public class DataOperation {
|
||||
|
||||
/**
|
||||
* CHAR() Converts a numeric value to its ASCII character string equivalent.
|
||||
*
|
||||
* Converts a numeric value to its ASCII character string equivalent.
|
||||
*
|
||||
* {talendTypes} char | Character
|
||||
*
|
||||
*
|
||||
* {Category} DataOperation
|
||||
*
|
||||
*
|
||||
* {param} int(1) i: numeric value
|
||||
*
|
||||
*
|
||||
* {example} CHAR(1):int
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static char CHAR(int i) {
|
||||
return Character.forDigit(i, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* DTX( ) Converts a decimal integer into its hexadecimal equivalent.
|
||||
*
|
||||
* Converts a decimal integer into its hexadecimal equivalent.
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} DataOperation
|
||||
*
|
||||
*
|
||||
* {param} int(1) i:decimal integer
|
||||
*
|
||||
*
|
||||
* {example} DTX(1)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static String DTX(int i) {
|
||||
return Integer.toHexString(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIX(double) Rounds a number of type Double to a number of type Long with the precision specified in the PRECISION
|
||||
* statement.
|
||||
*
|
||||
* Rounds a number of type Double to a number of type Long with the precision specified in the PRECISION statement.
|
||||
*
|
||||
* {talendTypes} long | Long
|
||||
*
|
||||
*
|
||||
* {Category} DataOperation
|
||||
*
|
||||
*
|
||||
* {param} double (0.0) d:double number
|
||||
*
|
||||
*
|
||||
* {example} FIX(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static long FIX(double d) {
|
||||
return Math.round(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* XTD( ) Converts a hexadecimal string into its decimal equivalent.
|
||||
*
|
||||
* Converts a hexadecimal string into its decimal equivalent.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} DataOperation
|
||||
*
|
||||
*
|
||||
* {param} string ("0") text: hexadecimal string
|
||||
*
|
||||
*
|
||||
* {example} XTD(\"1\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int XTD(String text) {
|
||||
return Integer.valueOf(text, 16);
|
||||
|
||||
@@ -9,13 +9,13 @@ public class Mathematical {
|
||||
|
||||
/**
|
||||
* Returns the absolute (positive) numeric value of an expression.
|
||||
*
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(10)
|
||||
*
|
||||
*
|
||||
* {example} ABS(-10) # 10
|
||||
*/
|
||||
public static double ABS(double a) {
|
||||
@@ -23,80 +23,80 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* ACOS( ) Calculates the trigonometric arc-cosine of an expression.
|
||||
*
|
||||
* Calculates the trigonometric arc-cosine of an expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(0.15)
|
||||
*
|
||||
*
|
||||
* {example} ACOS(0.15)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double ACOS(double a) {
|
||||
return Math.acos(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* ASIN( ) Calculates the trigonometric arc-sine of an expression.
|
||||
*
|
||||
* Calculates the trigonometric arc-sine of an expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(0.15)
|
||||
*
|
||||
*
|
||||
* {example} ASIN(0.15)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double ASIN(double a) {
|
||||
return Math.asin(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* ATAN( ) Calculates the trigonometric arctangent of an expression.
|
||||
*
|
||||
* Calculates the trigonometric arctangent of an expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} ATAN(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double ATAN(double a) {
|
||||
return Math.atan(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* BITAND( ) Performs a bitwise AND of two integers.
|
||||
*
|
||||
* Performs a bitwise AND of two integers.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} int(1) a :integer
|
||||
*
|
||||
*
|
||||
* {param} int(2) b :integer
|
||||
*
|
||||
*
|
||||
* {example} BITAND(1,1)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int BITAND(int a, int b) {
|
||||
return a & b;
|
||||
}
|
||||
|
||||
/**
|
||||
* BITNOT( ) Performs a bitwise NOT of a integers.
|
||||
*
|
||||
* Performs a bitwise NOT of a integers.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} int(10)
|
||||
*
|
||||
*
|
||||
* {example} BITNOT(10)
|
||||
*/
|
||||
public static int BITNOT(int a) {
|
||||
@@ -104,19 +104,19 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* BITOR( ) Performs a bitwise OR of two integers.
|
||||
*
|
||||
* Performs a bitwise OR of two integers.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} int(10) a: integer
|
||||
*
|
||||
*
|
||||
* {param} int(10) b: integer
|
||||
*
|
||||
*
|
||||
* {example} BITOR(10,10)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int BITOR(int a, int b) {
|
||||
return a | b;
|
||||
@@ -128,16 +128,16 @@ public class Mathematical {
|
||||
// BITTEST( ) Tests one bit of an integer.
|
||||
|
||||
/**
|
||||
* BITXOR( ) Performs a bitwise XOR of two integers.
|
||||
*
|
||||
* Performs a bitwise XOR of two integers.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} int(10) a: integer
|
||||
*
|
||||
*
|
||||
* {param} int(10) b: integer
|
||||
*
|
||||
*
|
||||
* {example} BITXOR(10,10)
|
||||
*/
|
||||
public static int BITXOR(int a, int b) {
|
||||
@@ -145,65 +145,65 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* COS( ) Calculates the trigonometric cosine of an angle.
|
||||
*
|
||||
* Calculates the trigonometric cosine of an angle.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} COS(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double COS(double a) {
|
||||
return Math.cos(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* COSH( ) Calculates the hyperbolic cosine of an expression.
|
||||
*
|
||||
* Calculates the hyperbolic cosine of an expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} COSH(3.14)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double COSH(double a) {
|
||||
return Math.cosh(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* DIV( ) Outputs the whole part of the real division of two real numbers.
|
||||
*
|
||||
* Outputs the whole part of the real division of two real numbers.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14) a: real number
|
||||
*
|
||||
*
|
||||
* {param} double(3.14) b: real number
|
||||
*
|
||||
*
|
||||
* {example} DIV(3.14,3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int DIV(double a, double b) {
|
||||
return (int) (a / b);
|
||||
}
|
||||
|
||||
/**
|
||||
* EXP( ) Calculates the result of base 'e' raised to the power designated by the value of the expression.
|
||||
*
|
||||
* Calculates the result of base 'e' raised to the power designated by the value of the expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} EXP(3.14)
|
||||
*/
|
||||
public static double EXP(double a) {
|
||||
@@ -211,14 +211,14 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* INT( ) Calculates the integer numeric value of an expression.
|
||||
*
|
||||
* Calculates the integer numeric value of an expression.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string("100")
|
||||
*
|
||||
*
|
||||
* {example} INT(\"100\")
|
||||
*/
|
||||
public static int INT(String e) {
|
||||
@@ -231,17 +231,17 @@ public class Mathematical {
|
||||
//
|
||||
|
||||
/**
|
||||
* FFIX( ) Converts a floating-point number to a string with a fixed precision. FFIX is provided for compatibility
|
||||
* Converts a floating-point number to a string with a fixed precision. FFIX is provided for compatibility
|
||||
* with existing software.
|
||||
*
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.1415926) d: real number
|
||||
*
|
||||
*
|
||||
* {param} int(2) precision: precision
|
||||
*
|
||||
*
|
||||
* {example}FFIX(3.1415926,2)
|
||||
*/
|
||||
public static String FFIX(double d, int precision) {
|
||||
@@ -252,16 +252,16 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* FFLT( ) Rounds a number to a string with a precision of 14.
|
||||
*
|
||||
* Rounds a number to a string with a precision of 14.
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} FFLT(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static String FFLT(double d) {
|
||||
return Mathematical.FFIX(d, 14);
|
||||
@@ -272,34 +272,34 @@ public class Mathematical {
|
||||
// FSUB( ) Performs floating-point subtraction on two numeric values.
|
||||
|
||||
/**
|
||||
* LN( ) Calculates the natural logarithm of an expression in base 'e'.
|
||||
*
|
||||
* Calculates the natural logarithm of an expression in base 'e'.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} LN(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double LN(double a) {
|
||||
return Math.log(a) / Math.E;
|
||||
}
|
||||
|
||||
/**
|
||||
* MOD( ) Calculates the modulo (the remainder) of two expressions.
|
||||
*
|
||||
* Calculates the modulo (the remainder) of two expressions.
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3) a: double
|
||||
*
|
||||
*
|
||||
* {param} double(2) b: double
|
||||
*
|
||||
*
|
||||
* {example} MOD(3,2)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double MOD(double a, double b) {
|
||||
return a % b;
|
||||
@@ -310,16 +310,16 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* NEG( ) Returns the arithmetic additive inverse of the value of the argument.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Returns the arithmetic additive inverse of the value of the argument.
|
||||
*
|
||||
*
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} NEG(3.14)
|
||||
*/
|
||||
public static double NEG(double a) {
|
||||
@@ -327,16 +327,16 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* NUM( ) Returns true (1) if the argument is a numeric data type; otherwise, returns false (0).
|
||||
*
|
||||
* Returns true (1) if the argument is a numeric data type; otherwise, returns false (0).
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string("1")
|
||||
*
|
||||
*
|
||||
* {example} NUM(\"1\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int NUM(String e) {
|
||||
if (e.matches("\\d+")) { //$NON-NLS-1$
|
||||
@@ -349,16 +349,16 @@ public class Mathematical {
|
||||
// power.
|
||||
|
||||
/**
|
||||
* REAL( ) Converts a numeric expression into a real number without loss of accuracy.
|
||||
*
|
||||
* Converts a numeric expression into a real number without loss of accuracy.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string("3.14")
|
||||
*
|
||||
*
|
||||
* {example} REAL(\"3.14\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double REAL(String e) {
|
||||
return Double.valueOf(e);
|
||||
@@ -366,55 +366,55 @@ public class Mathematical {
|
||||
|
||||
// REM( ) Calculates the value of the remainder after integer division is
|
||||
// performed.
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* RND( ) Generates a random number between zero and a specified number minus one.
|
||||
*
|
||||
* Generates a random number between zero and a specified number minus one.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} RND(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double RND(double a) {
|
||||
return Math.random() * a;
|
||||
}
|
||||
|
||||
/**
|
||||
* SADD( ) Adds two string numbers and returns the result as a string number.
|
||||
*
|
||||
* Adds two string numbers and returns the result as a string number.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string("10") a: string number
|
||||
*
|
||||
*
|
||||
* {param} string("10") b: string number
|
||||
*
|
||||
*
|
||||
* {example} SADD(\"10\",\"10\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double SADD(String a, String b) {
|
||||
return Double.valueOf(a) + Double.valueOf(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* SCMP( ) Compares two string numbers.
|
||||
*
|
||||
* Compares two string numbers.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string("12") a: string
|
||||
*
|
||||
*
|
||||
* {param} string("13") b: string
|
||||
*
|
||||
*
|
||||
* {example} SCMP(\"12\",\"13\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int SCMP(String a, String b) {
|
||||
double da = Double.valueOf(a);
|
||||
@@ -429,138 +429,137 @@ public class Mathematical {
|
||||
}
|
||||
|
||||
/**
|
||||
* SDIV( ) Outputs the quotient of the whole division of two integers.
|
||||
*
|
||||
* Outputs the quotient of the whole division of two integers.
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} int(10) a: int
|
||||
*
|
||||
*
|
||||
* {param} int(10) b: int
|
||||
*
|
||||
*
|
||||
* {example} SDIV(10,20)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int SDIV(int a, int b) {
|
||||
return (int) (a / b);
|
||||
}
|
||||
|
||||
/**
|
||||
* SIN( ) Calculates the trigonometric sine of an angle.
|
||||
*
|
||||
* Calculates the trigonometric sine of an angle.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} SIN(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double SIN(double a) {
|
||||
return Math.sin(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* SINH( ) Calculates the hyperbolic sine of an expression.
|
||||
*
|
||||
* Calculates the hyperbolic sine of an expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14)
|
||||
*
|
||||
*
|
||||
* {example} SINH(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double SINH(double a) {
|
||||
return Math.sinh(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* SMUL( ) Multiplies two string numbers.
|
||||
*
|
||||
* Multiplies two string numbers.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string("3.14") a: string
|
||||
*
|
||||
*
|
||||
* {param} string("3.14") b: string
|
||||
*
|
||||
*
|
||||
* {example} SMUL(\"3.14\",\"3.14\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double SMUL(String a, String b) {
|
||||
return Double.valueOf(a) * Double.valueOf(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* SQRT( ) Calculates the square root of a number.
|
||||
*
|
||||
* Calculates the square root of a number.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(4)
|
||||
*
|
||||
*
|
||||
* {example} SQRT(4.0)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double SQRT(double a) {
|
||||
return Math.sqrt(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* SSUB( ) Subtracts one string number from another and returns the result as a string number.
|
||||
*
|
||||
* Subtracts one string number from another and returns the result as a string number.
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} string(20) a: string
|
||||
*
|
||||
*
|
||||
* {param} string(10) b: string
|
||||
*
|
||||
*
|
||||
* {example} SSUB(\"20\",\"10\")
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static String SSUB(String a, String b) {
|
||||
return Double.toString(Double.valueOf(a) - Double.valueOf(b));
|
||||
}
|
||||
|
||||
/**
|
||||
* TAN( ) Calculates the trigonometric tangent of an angle.
|
||||
*
|
||||
* Calculates the trigonometric tangent of an angle.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14) a: double
|
||||
*
|
||||
*
|
||||
* {example} TAN(3.14)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double TAN(double a) {
|
||||
return Math.tan(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* TANH( ) Calculates the hyperbolic tangent of an expression.
|
||||
*
|
||||
* Calculates the hyperbolic tangent of an expression.
|
||||
*
|
||||
* {talendTypes} double | Double
|
||||
*
|
||||
*
|
||||
* {Category} Mathematical
|
||||
*
|
||||
*
|
||||
* {param} double(3.14) a: double
|
||||
*
|
||||
*
|
||||
* {example} TANH(3.14)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static double TANH(double a) {
|
||||
return Math.tanh(a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,21 +13,21 @@ public class Numeric {
|
||||
|
||||
/**
|
||||
* return an incremented numeric id
|
||||
*
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {Category} Numeric
|
||||
*
|
||||
*
|
||||
* {param} string("s1") sequence identifier
|
||||
*
|
||||
*
|
||||
* {param} int(1) start value
|
||||
*
|
||||
*
|
||||
* {param} int(1) step
|
||||
*
|
||||
*
|
||||
* {example} sequence("s1", 1, 1) # 1, 2, 3, ...
|
||||
*
|
||||
*
|
||||
* {example} sequence("s2", 100, -2) # 100, 98, 96, ...
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static Integer sequence(String seqName, int startValue, int step) {
|
||||
if (seq_Hash.containsKey(seqName)) {
|
||||
@@ -41,15 +41,15 @@ public class Numeric {
|
||||
|
||||
/**
|
||||
* create a sequence if not exists and put a new startValue
|
||||
*
|
||||
*
|
||||
* {Category} Numeric
|
||||
*
|
||||
*
|
||||
* {param} string("s1") sequence identifier
|
||||
*
|
||||
*
|
||||
* {param} int(1) start value
|
||||
*
|
||||
*
|
||||
* {example} sequence("s1", 1)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public static void resetSequence(String seqName, int startValue) {
|
||||
@@ -58,13 +58,13 @@ public class Numeric {
|
||||
|
||||
/**
|
||||
* remove a sequence
|
||||
*
|
||||
*
|
||||
* {Category} Numeric
|
||||
*
|
||||
*
|
||||
* {param} string("s1") sequence identifier
|
||||
*
|
||||
*
|
||||
* {example} sequence("s1")
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public static void removeSequence(String seqName) {
|
||||
@@ -75,19 +75,19 @@ public class Numeric {
|
||||
|
||||
/**
|
||||
* return a random int between min and max
|
||||
*
|
||||
*
|
||||
* {Category} Numeric
|
||||
*
|
||||
*
|
||||
* {talendTypes} int | Integer
|
||||
*
|
||||
*
|
||||
* {param} int(0) min value
|
||||
*
|
||||
*
|
||||
* {param} int(100) max value
|
||||
*
|
||||
*
|
||||
* {example} random(3, 10) # 7, 4, 8, ...
|
||||
*
|
||||
*
|
||||
* {example} random(0, 100) # 93, 12, 83, ...
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static Integer random(Integer min, Integer max) {
|
||||
return ((Long) Math.round(min - 0.5 + (Math.random() * (max - min + 1)))).intValue();
|
||||
@@ -95,17 +95,17 @@ public class Numeric {
|
||||
|
||||
/**
|
||||
* return numbers using an implied decimal format.
|
||||
*
|
||||
*
|
||||
* {Category} Numeric
|
||||
*
|
||||
*
|
||||
* {talendTypes} float | Float
|
||||
*
|
||||
*
|
||||
* {param} String("9V99") format: float pointing format.
|
||||
*
|
||||
*
|
||||
* {param} String("123") toConvert: read this value.
|
||||
*
|
||||
*
|
||||
* {example} convertImpliedDecimalFormat("9V99", "123") result: 1.23 ...
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static Float convertImpliedDecimalFormat(String format, String toConvert) {
|
||||
BigDecimal decimal = Numeric.convertString2BigDecimal(format,toConvert);
|
||||
|
||||
@@ -8,31 +8,31 @@ package routines;
|
||||
public class Relational {
|
||||
|
||||
/**
|
||||
* ISNULL( ) Indicates when a variable is the null value.
|
||||
*
|
||||
* Indicates when a variable is the null value.
|
||||
*
|
||||
* {talendTypes} boolean | Boolean
|
||||
*
|
||||
*
|
||||
* {Category} Relational
|
||||
*
|
||||
*
|
||||
* {param} Object(null)
|
||||
*
|
||||
*
|
||||
* {example} ISNULL(null)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static boolean ISNULL(Object variable) {
|
||||
return variable == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOT( ) Returns the complement of the logical value of an expression.
|
||||
*
|
||||
* Returns the complement of the logical value of an expression.
|
||||
*
|
||||
* {talendTypes} boolean | Boolean
|
||||
*
|
||||
*
|
||||
* {Category} Relational
|
||||
*
|
||||
*
|
||||
* {param} boolean(true)
|
||||
*
|
||||
*
|
||||
* {example} NOT(false)
|
||||
*/
|
||||
public static boolean NOT(boolean expression) {
|
||||
|
||||
@@ -211,6 +211,15 @@ public class TalendDate {
|
||||
* @param ignoreTimeZone (if true ignore TimeZone when pare date with pattern)
|
||||
* @return the result whether the stringDate is a date string that with a right pattern
|
||||
*
|
||||
* {talendTypes} Boolean
|
||||
*
|
||||
* {Category} TalendDate
|
||||
*
|
||||
* {param} String(mydate) stringDate : the date to judge
|
||||
*
|
||||
* {param} String("yyyy-MM-dd HH:mm:ss") pattern : the specified pattern
|
||||
*
|
||||
* {param} boolean(true) ignoreTimeZone : ignore the time zone
|
||||
*/
|
||||
public static boolean isDate(String stringDate, String pattern, boolean ignoreTimeZone) {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
@@ -328,7 +337,7 @@ public class TalendDate {
|
||||
*
|
||||
* {param} date(myDate) date : the date to update
|
||||
*
|
||||
* {param} date(addValue) nb : the added value
|
||||
* {param} int(addValue) nb : the added value
|
||||
*
|
||||
* {param} date("MM") dateType : the part to add
|
||||
*
|
||||
@@ -382,11 +391,11 @@ public class TalendDate {
|
||||
*
|
||||
* {Category} TalendDate
|
||||
*
|
||||
* {param} date(myDate) date : the date to update
|
||||
* {param} String("") string : date represent in string
|
||||
*
|
||||
* {param} date(pattern) string : the pattern
|
||||
* {param} String("yyyy-MM-dd") pattern : date pattern
|
||||
*
|
||||
* {param} date(addValue) nb : the added value
|
||||
* {param} int(addValue) nb : the added value
|
||||
*
|
||||
* {param} date("MM") dateType : the part to add
|
||||
*
|
||||
@@ -463,6 +472,8 @@ public class TalendDate {
|
||||
*
|
||||
* {param} String("MM") dateType : the difference on the specified part
|
||||
*
|
||||
* {param} boolean(true) ignoreDST : ignore daylight saving time or not.
|
||||
*
|
||||
* {examples}
|
||||
*
|
||||
* ->> diffDate(2012/03/26 00:00:00, 2012/03/24 00:00:00, "dd", true) : return 2 not 1 in GMT+1#
|
||||
@@ -565,8 +576,6 @@ public class TalendDate {
|
||||
*
|
||||
* {param} date(myDate2) date2 : the second date to compare
|
||||
*
|
||||
* {param} String("MM") dateType : the difference on the specified part
|
||||
*
|
||||
* {examples}
|
||||
*
|
||||
* ->> diffDate(2012/03/26 00:00:00, 2012/03/24 00:00:00) : return 2 not 1 in GMT+1#
|
||||
@@ -1010,24 +1019,6 @@ public class TalendDate {
|
||||
return new Date(random);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Method used for tests only.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
// test_formatDate();
|
||||
// test_isDate();
|
||||
// test_getRandomDate();
|
||||
// System.out.println(getPartOfDate("DAY_OF_WEEK_IN_MONTH", parseDate("yyyy-MM-dd", "2010-12-26")));
|
||||
// System.out.println(getPartOfDate("WEEK_OF_MONTH", parseDate("yyyy-MM-dd", "2010-12-26")));
|
||||
|
||||
System.out.println(TalendDate.diffDateFloor(TalendDate.parseDate("yyyy/MM/dd hh:mm:ss.SSS", "2011/05/10 14:15:16.788"),
|
||||
TalendDate.parseDate("yyyy/MM/dd hh:mm:ss.SSS", "2010/05/10 14:15:16.789"), "MM"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Testcase:
|
||||
|
||||
@@ -25,14 +25,14 @@ public class TalendString {
|
||||
|
||||
/**
|
||||
* return Replace the special character(e.g. <,>,& etc) within a string for XML file.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} TalendString
|
||||
*
|
||||
*
|
||||
* {param} string("") input: The string with the special character(s) need to be replaced.
|
||||
*
|
||||
*
|
||||
* {example} replaceSpecialCharForXML("<title>Empire <>Burlesque</title>") # <title>Empire <>Burlesque</title>
|
||||
*/
|
||||
public static String replaceSpecialCharForXML(String input) {
|
||||
@@ -45,7 +45,13 @@ public class TalendString {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* check CDATA for xml
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
* {Category} TalendString
|
||||
*
|
||||
* {param} string("") input: the CDATA format data to be checked.
|
||||
*/
|
||||
public static String checkCDATAForXML(String input) {
|
||||
if (input.startsWith("<![CDATA[") && input.endsWith("]]>")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -57,14 +63,14 @@ public class TalendString {
|
||||
|
||||
/**
|
||||
* getAsciiRandomString : Return a randomly generated String
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} TalendString
|
||||
*
|
||||
*
|
||||
* {param} int(6) length: length of the String to return
|
||||
*
|
||||
*
|
||||
* {example} getAsciiRandomString(6) # Art34Z
|
||||
*/
|
||||
public static String getAsciiRandomString(int length) {
|
||||
@@ -86,20 +92,20 @@ public class TalendString {
|
||||
|
||||
/**
|
||||
* talendTrim: Returns a copy of the string, with leading and trailing specified char omitted.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} TalendString
|
||||
*
|
||||
*
|
||||
* {param} string("") origin: The original string need to be trimed.
|
||||
*
|
||||
*
|
||||
* {param} char(' ') padding_char: The padding char for triming.
|
||||
*
|
||||
*
|
||||
* {param} int(0) align: The alignment of the content in the original string. Positive int for right, negative int
|
||||
* for left and zero for center. Positive integer to trim the left part, zero to trim both the left and the right part, negative to trim the right part.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {example} talendTrim("$$talend open studio$$$$", '$', 0) # talend open studio
|
||||
*/
|
||||
public static String talendTrim(String origin, char padding_char, int align) {
|
||||
@@ -256,15 +262,15 @@ public class TalendString {
|
||||
|
||||
/**
|
||||
* removeAccents: remove accents from the string given.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} TalendString
|
||||
*
|
||||
*
|
||||
* {param} string("") text: Text to remove accents.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {example} removeAccents("Accès à la base")
|
||||
*/
|
||||
public static String removeAccents(String text) {
|
||||
@@ -283,15 +289,15 @@ public class TalendString {
|
||||
}
|
||||
/**
|
||||
* unionString: Union the variable number of arguments with separator String
|
||||
*
|
||||
*
|
||||
* @param separator union arguments .
|
||||
* @param objects variable number of arguments.
|
||||
* @return A union string.
|
||||
*
|
||||
*
|
||||
* {talendTypes} String
|
||||
*
|
||||
*
|
||||
* {Category} TalendString
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static String unionString(String separator,Object... objects){
|
||||
if(objects!=null){
|
||||
|
||||
Reference in New Issue
Block a user