Source:
public void parseMetadataFromHeader ( ) { com.google.gerrit.server.mail.receive.MailMessage.Builder b = com.google.gerrit.server.mail.receive.MailMessage.builder ( ) ; b.id ( "" ) ; b.dateReceived ( new org.joda.time.DateTime ( ) ) ; b.subject ( "" ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.CHANGE_NUMBER ) ) + "123" ) ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.PATCH_SET ) ) + "1" ) ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.MESSAGE_TYPE ) ) + "comment" ) ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.TIMESTAMP ) ) + "Tue, 25 Oct 2016 02:11:35 -0700" ) ) ; com.google.gerrit.server.mail.Address author = new com.google.gerrit.server.mail.Address ( "Diffy" , "test@gerritcodereview.com" ) ; b.from ( author ) ; com.google.gerrit.server.mail.receive.MailMetadata meta = com.google.gerrit.server.mail.receive.MetadataParser.parse ( b.build ( ) ) ; com.google.common.truth.Truth.assertThat ( meta.author ) . isEqualTo ( author.getEmail ( ) ) ; com.google.common.truth.Truth.assertThat ( meta.changeNumber ) . isEqualTo ( 123 ) ; com.google.common.truth.Truth.assertThat ( meta.patchSet ) . isEqualTo ( 1 ) ; com.google.common.truth.Truth.assertThat ( meta.messageType ) . isEqualTo ( "comment" ) ; com.google.common.truth.Truth.assertThat ( meta.timestamp.getTime ( ) ) . isEqualTo ( new org.joda.time.DateTime ( 2016 , 10 , 25 , 9 , 11 , 35 , 0 , org.joda.time.DateTimeZone.UTC ) . getMillis ( ) ) ; }

Target:
public void parseMetadataFromHeader ( ) { com.google.gerrit.server.mail.receive.MailMessage.Builder b = com.google.gerrit.server.mail.receive.MailMessage.builder ( ) ; b.id ( "" ) ; b.dateReceived ( java.time.Instant.now ( ) ) ; b.subject ( "" ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.CHANGE_NUMBER ) ) + "123" ) ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.PATCH_SET ) ) + "1" ) ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.MESSAGE_TYPE ) ) + "comment" ) ) ; b.addAdditionalHeader ( ( ( com.google.gerrit.server.mail.MetadataName.toHeaderWithDelimiter ( MetadataName.TIMESTAMP ) ) + "Tue, 25 Oct 2016 02:11:35 -0700" ) ) ; com.google.gerrit.server.mail.Address author = new com.google.gerrit.server.mail.Address ( "Diffy" , "test@gerritcodereview.com" ) ; b.from ( author ) ; com.google.gerrit.server.mail.receive.MailMetadata meta = com.google.gerrit.server.mail.receive.MetadataParser.parse ( b.build ( ) ) ; com.google.common.truth.Truth.assertThat ( meta.author ) . isEqualTo ( author.getEmail ( ) ) ; com.google.common.truth.Truth.assertThat ( meta.changeNumber ) . isEqualTo ( 123 ) ; com.google.common.truth.Truth.assertThat ( meta.patchSet ) . isEqualTo ( 1 ) ; com.google.common.truth.Truth.assertThat ( meta.messageType ) . isEqualTo ( "comment" ) ; com.google.common.truth.Truth.assertThat ( meta.timestamp.toInstant ( ) ) . isEqualTo ( java.time.LocalDateTime.of ( 2016 , java.time.Month.OCTOBER , 25 , 9 , 11 , 35 ) . atOffset ( java.time.ZoneOffset.UTC ) . toInstant ( ) ) ; }