从银行交易中获取日期

时间:2019-01-30 07:04:06

标签: java android

我想从银行发送的消息中获取所有详细信息,在其他字段中,我尝试从这些消息中获取日期 但无法获得所有日期类型

我从所有这些中获得了收益,但其他领域中的问题

smsDto.setBody("Dear Customer, Your Ac XXXXXXXX5666 is credited with INR8,922.00 on 16 Feb. Info. INF*000080483346*SALARY. Your Net Available Bal is INR 8,922.00.");
        smsDto.setBody("A/c NN5715 debited for Rs 2000; ATM WDL. A/c Bal(sub to chq realisatn) Rs13286.23 on 24APR 21:19hr. Call 1800226999 to block your card if not used by you.");
        smsDto.setBody("Dear Customer, your Account Number XXXXXX6377 has been credited by Rs 215.000 being DBT/DBTL funds transfer on 19/05/2015 - CENTRAL BANK OF INDIA");
        smsDto = new SmsDto();
        smsDto.setBody("Dear Customer, your Account XX0770 has been credited with INR 20,000.00 on 21-Dec-18. Info: BIL*INFT*001602773462*STEALT. The Available Balance is INR 23,547.77.");

    }
AND CODE IS 
String getDate(String msgBody){
        String date="";
        Pattern regEx = Pattern.compile("(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\\d\\d");// Pattern.compile("[0-9]*[Xx\\*]*[0-9]*[Xx\\*]+[0-9]{3,}");
        Matcher m = regEx.matcher(msgBody);
        if (m.find()) {
            try {
                Log.e("date= ", "" + m.group(0));
                 date = (m.group(0));
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            Log.e("No_matchedValue ", "No_matchedValue ");
        }
        return date;
    }

1 个答案:

答案 0 :(得分:0)

我看到您正在从两个字段中提取日期-2015年5月19日和18年12月21日

对于上述两种模式,您都可以尝试以下正则表达式

mapKey = Highcharts.map['custom/world-continents'];

series : [{
          data : data,
          mapData: mapKey,
        }]