For smooth compact oriented Riemannian manifolds$M$of dimension 4$k$+2,$k$≥0, with or without boundary, and a vector bundle$F$on$M$with an inner product and a flat connection, we construct a modification of the Hodge star operator on the middle-dimensional (parabolic) cohomology of$M$twisted by$F$. This operator induces a canonical complex structure on the middle-dimensional cohomology space that is compatible with the natural symplectic form given by integrating the wedge product. In particular, when$k$=0 we get a canonical almost complex structure on the non-singular part of the moduli space of flat connections on a Riemann surface, with monodromies along boundary components belonging to fixed conjugacy classes when the surface has boundary, that is compatible with the standard symplectic form on the moduli space.