This article studies the unmanned aerial vehicle (UAV) trajectory planning problem in a UAV-enabled environmental monitoring system and considers a typical data collection scenario where a UAV is dispatched to a geographical area to collect time-constrained data in a set of monitoring areas and transmit collected data to a ground base station (GBS). We formulate the UAV trajectory planning problem as an optimization problem with the objective to minimize the UAV’s mission completion time by jointly optimizing the UAV’s flying speeds, hovering positions, and visiting sequence, taking into account the Age of Information (AoI) of data in monitoring areas, and the on-board energy of the UAV. To solve the problem, we decompose the formulated optimization problem into two subproblems: a UAV speed optimization problem and a UAV path optimization problem, and propose successive convex approximation (SCA) method-based and generic algorithm (GA)-based algorithms to solve the subproblems. Based on the proposed algorithms, we further propose an AoI-and-energy-aware trajectory optimization (AoI-EaTO) algorithm to solve the main problem. Simulation results show that the proposed AoI-EaTO algorithm can find a better solution to the problem than two benchmark algorithms. Moreover, given the UAV’s on-board energy and maximum speed as well as the positions of the GBS and monitoring areas, the AoI limitation threshold that the system is able to satisfy can be obtained through simulation results. This threshold can be used to decide if the UAV is able to finish a particular data collection mission, which is useful to the deployment of the mission.