LicenseServer/Example/src/main/java/me/braydon/example/Main.java

33 lines
1.2 KiB
Java
Raw Normal View History

2023-05-31 21:33:37 -07:00
package me.braydon.example;
2023-06-01 21:29:45 -07:00
import java.time.Instant;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalField;
import java.util.Date;
import java.util.concurrent.TimeUnit;
2023-05-31 21:33:37 -07:00
/**
* @author Braydon
*/
public final class Main {
public static void main(String[] args) {
2023-06-01 21:29:45 -07:00
LicenseExample.LicenseResponse response = LicenseExample.check("XXXX-XXXX-XXXX-XXXX", "Example");
2023-05-31 21:33:37 -07:00
if (!response.isValid()) { // License isn't valid
System.err.println("Invalid license: " + response.getError());
return;
}
// License is valid
System.out.println("License is valid!");
if (response.getOwnerName() != null) {
System.out.println("Welcome " + response.getOwnerName() + "!");
}
if (response.getDescription() != null) {
System.out.println("Description: " + response.getDescription()); // License description
}
if (response.isPermanent()) { // License is permanent
System.out.println("Your license is permanent");
2023-06-01 21:25:50 -07:00
} else { // License has an expiration date
System.out.printf("Your license will expire at: %s%n", response.getExpires().toInstant());
2023-05-31 21:33:37 -07:00
}
}
}