public static void updateTimestamp(Versioning target) {
target.setLastUpdated(TimeUtil.getUTCTimestamp());
}
public static Snapshot createSnapshot(String version) {
Snapshot sn = new Snapshot();
if (version == null || version.length() < 3) {
return sn;
}
String utc = TimeUtil.getUTCTimestamp();
sn.setTimestamp(utc);
if (version.endsWith("-SNAPSHOT")) {
return sn;
}
int pos = version.lastIndexOf('-');
if (pos == -1) {
throw new IllegalArgumentException();
}
String sbn = version.substring(pos + 1);
int bn = Integer.parseInt(sbn);
sn.setBuildNumber(bn);
String sts = version.substring(0, pos);
pos = sts.lastIndexOf('-');
if (pos == -1) {
throw new IllegalArgumentException();
}
sn.setTimestamp(sts.substring(pos + 1));
return sn;
}