I'm using web3j to analyze transactions. How can I get transactions of a specific contract (assuming I got it's address) in some time frame (or blocks interval) and how can I know if ERC20 tokens were transferred in a transaction once I get it?
You could use an API like the one provided by EtherScan or get an Infura account, but, alas, these are centralised solutions.
A fully decentralised method would be to run a full node and use the JSON-RPC commands.
Now you can query the list of transactions for your contract address. You can take their inputs and decode them, provided you have the contract's ABI. Here's some sample code doing that for an ERC20 transaction on Ropsten.
If you know the contract adheres to the ERC20 standard and the name of the function is
transfer when the input is decoded, that's an ERC20 token transfer.