This example shows how to create the raw Swiss Payments Code. It is the textual represenation of all data encoded in the QR code.

import ch.codeblock.qrinvoice.QrInvoiceCodeCreator;
import ch.codeblock.qrinvoice.model.QrInvoice;
import ch.codeblock.qrinvoice.model.builder.QrInvoiceBuilder;

import java.time.LocalDate;
import java.time.Month;

// ..

final QrInvoice qrInvoice = // create using QrInvoiceBuilder;

// the resulting String is the Swiss Payments Code which is the one encoded in the QR-Code
final String swissPaymentsCode = QrInvoiceCodeCreator.create()
        .qrInvoice(qrInvoice)
        .createSwissPaymentsCode();
System.out.println(swissPaymentsCode);

Prints a SPC like the following

SPC
0100
1
CH4431999123000889012
Robert Schneider AG
Rue du Lac
1268
2501
Biel
CH
Robert Schneider Services Switzerland AG
Rue du Lac
1268/3/1
2501
Biel
CH
1949.75
CHF
2019-10-31
Pia-Maria Rutschmann-Schnyder
Grosse Marktgasse
28
9400
Rorschach
CH
SCOR
RF18539007547034
Instruction of 15.09.2019##S1/01/20170309/11/10201409/20/1400 0000/22/36958/30/CH106017086/40/1020/41/3010