You can use SuppressionCommentFilter check to do this.
Configure the properties values like (in your checkstyle configuration file)
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Check\:OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="Check\:ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
Now for the required lines, you can do like
//Check:OFF: MagicNumber
DateTime dateTime = new DateTime(2013, 2, 27, 23, 0):
dateTime.plusHours(57);
//Check:ON: MagicNumber
This will only suppress MagicNumber checks
, the rest checks will work here.
You can suppress Multiple checcks too, like
//Check:OFF: MagicNumber|Indentation
Code Here
//Check:ON: MagicNumber|Indentation
this will suppress only MagicNumber and Indentation Checks
. Other checks will work fine.