public static long getLongWithCurrentDate ( String value , String timezone ) { if ( Strings . isNullOrEmpty ( value ) ) { return 0 ; } DateTime time = getCurrentTime ( timezone ) ; DateTimeFormatter dtFormatter = DateTimeFormat . forPattern ( CURRENT_DATE_FORMAT ) . withZone ( time . getZone ( ) ) ; if ( value . toUpperCase ( ) . startsWith ( CURRENT_DAY ) ) { return Long . parseLong ( dtFormatter . print ( time . minusDays ( Integer . parseInt ( value . substring ( CURRENT_DAY . length ( ) + 1 ) ) ) ) ) ; } if ( value . toUpperCase ( ) . startsWith ( CURRENT_HOUR ) ) { return Long . parseLong ( dtFormatter . print ( time . minusHours ( Integer . parseInt ( value . substring ( CURRENT_HOUR . length ( ) + 1 ) ) ) ) ) ; } return Long . parseLong ( value ) ; }
Helper method for getting a value containing CURRENTDAY - 1 or CURRENTHOUR - 1 in the form yyyyMMddHHmmss