mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
if the string is empty after replacement,return creation time.
This commit is contained in:
@@ -19,6 +19,8 @@ package forge.deck;
|
|||||||
|
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public abstract class DeckBase implements Serializable, Comparable<DeckBase>, InventoryItem {
|
public abstract class DeckBase implements Serializable, Comparable<DeckBase>, InventoryItem {
|
||||||
private static final long serialVersionUID = -7538150536939660052L;
|
private static final long serialVersionUID = -7538150536939660052L;
|
||||||
@@ -145,9 +147,9 @@ public abstract class DeckBase implements Serializable, Comparable<DeckBase>, In
|
|||||||
public final String getBestFileName() {
|
public final String getBestFileName() {
|
||||||
//string operator hard to guarantee filename legal,only replace some not allowed as file names characters
|
//string operator hard to guarantee filename legal,only replace some not allowed as file names characters
|
||||||
final String result = name.replaceAll("[\\/:*?\"<>|]","");
|
final String result = name.replaceAll("[\\/:*?\"<>|]","");
|
||||||
if (result == "") {
|
if (result.isEmpty()) {
|
||||||
//"getBestFileName" sha1 value
|
final String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm"));
|
||||||
return "bc2b4ac6bf8dd84112c79e4c733b0b5bd8f057b3";
|
return createTime;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user