A charging device includes a charging member that charges a body to be
charged; a detector that detects an AC component of a current flowing
through the charging member; an integration section that integrates the
AC component of the current detected by the detector; a controller that
controls the current flowing through the charging member, according to a
result of integration executed by the integration section; a periodic
signal generating section that generates a periodic signal having a cycle
period corresponding to a cycle period of the AC component; and an
integration period adjusting section that adjusts a period of integration
executed by the integration section, with reference to the periodic
signal.