Back to project page SMSAlive.
The source code is released under:
Apache License
If you think the Android project SMSAlive listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.futuretech.app.smsalive.Application.Services.impl; /*from w ww. j av a2 s . c o m*/ import android.content.Context; import com.futuretech.app.smsalive.Domain.models.AccountTransaction; import com.futuretech.app.smsalive.Application.Services.TranscactionTypeHandler; import org.apache.commons.lang3.StringUtils; import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; /** * Created by ironhulk on 2014/12/02. */ public class DepositHandler extends TranscactionTypeHandler { AccountTransaction accountTransaction; StringUtils utils; @Override public void handleAccountType(String message, Context c) { accountTransaction = new AccountTransaction(); utils = new StringUtils(); if(message.substring(0, 4).contains("Absa")){ int isDeposit = message.indexOf("Dep"); if(isDeposit!=-1) { String witDrawPassOn = message.substring(6); accountTransaction.setAccountNumber(witDrawPassOn.substring(4, 8)); accountTransaction.setAccountType(witDrawPassOn.substring(0, 4)); LocalDate date = LocalDate.parse(witDrawPassOn.substring(isDeposit, isDeposit+7), DateTimeFormat.forPattern("dd/MM/yyyy")); accountTransaction.setTransactionDate(date); String available = "Available"; String strippedUselessWords = utils.substringBefore(witDrawPassOn.substring(witDrawPassOn.indexOf("-")+2 ),","); String paymentPerson = utils.substringBefore(witDrawPassOn.substring(witDrawPassOn.indexOf(strippedUselessWords)+strippedUselessWords.length()+2),","); accountTransaction.setTransactionPlace(paymentPerson); String transactionAmount = witDrawPassOn.substring(witDrawPassOn.indexOf(paymentPerson) + paymentPerson.length() + 3, witDrawPassOn.indexOf("Available") - 2); accountTransaction.setTransactionAmount(Double.valueOf(transactionAmount.replace(",", ""))); accountTransaction.setTransactionType("Deposit"); String balance = witDrawPassOn.substring(witDrawPassOn.indexOf(available) + available.length() + 2, witDrawPassOn.indexOf("Help") - 2); accountTransaction.setAccountBalance(Double.valueOf(balance.replace(",", ""))); } } } }