Trajectory planning of a spacecraft in formation flying is considered in this paper. Based on the equations of motion of the spacecraft that incorporate effects of J2 geopotential disturbance, time-periodic realtive equations of motion are derived. Using the Floquet theorem to periodic terms due to J2 disturbance, approximate solutions for eigenvalues and eigenvectors of the state transition matrix of the linearized equations are obtained by perturbation calculation and characteristics of relative motion are discussed. A correction term of an initial velocity of formation flying to suppress the effects of J2 disturbance is obtained based on the approximate solutions. Numerical studies are conducted to verify the proposed trajectory planning.