The increasing development of renewable energy sources requires more flexible technologies to be applied in building energy systems and a flexible controlled resource for the power grid. This work focuses on investigating the flexibility potential of building thermal storage and battery energy storage. Firstly, an autoregressive model with exogenous inputs is proposed to forecast the dynamic cooling demand and, based on that, a mixed integer linear model is formulated to optimize the dispatch of building energy systems with minimal operating costs. A factory building located in Huizhou, China is used as a case study. The results show that the ARX model can accurately predict the thermal load hourly. The model’s level of fit is above 81%. The optimization objectives influence the development of the flexibility potential when building thermal storage and battery energy storage are considered. In this work, the economic objective is applied first to discuss the flexibility potential. The results show that, in this studied case, the operational cost decreased by 5.3% by using battery energy storage and further decreased by 4.0% by using building thermal storage. However, the results also reveal that unilaterally pursuing minimal operational costs results in larger peak valley difference of feeder power. The peak-valley difference of the feeder power increased from 714 kW to 1245 kW and 1689 kW respectively when the battery energy storage and building thermal storage were employed for the economic dispatch of the building energy system. Therefore, this work retests the flexibility potential of battery energy storage and building thermal storage by adding a constraint for feeder power difference. The results show that the operational costs can be still reduced greatly without damaging the stability of the power feeder.