# StringHelper
> Utility class for string parsing, formatting, time conversions, and encoding.
`gg.lode.bookshelfapi.api.util.StringHelper`
---
## Signature
```java
public class StringHelper
```
---
## Static Methods
### Time Parsing
| Method | Return Type | Description |
|--------|-------------|-------------|
| `parseShortTimeStringToMillis(String input)` | `long` | Parses a short time string (e.g., `"5m"`, `"1h30m"`) into milliseconds. |
| `getTimeDuration(int seconds)` | `String` | Formats seconds into a human-readable duration string. |
| `getTimeString(long millis)` | `String` | Formats milliseconds into a time string. |
| `getTimeString(long millis, String format)` | `String` | Formats milliseconds using a custom format. |
| `getShortTimeCode(long millis)` | `String` | Formats milliseconds into a short time code (e.g., `"5m"`, `"1h"`). |
### Encoding
| Method | Return Type | Description |
|--------|-------------|-------------|
| `encodeListToBase64(List<String> list)` | `String` | Encodes a list of strings to a Base64 string. |
| `decodeBase64ToList(String encoded)` | `List<String>` | Decodes a Base64 string back to a list of strings. |
### Formatting
| Method | Return Type | Description |
|--------|-------------|-------------|
| `format(String template, Object... args)` | `String` | Formats a string with positional arguments. |
| `format(String template, Map<String, Object> args)` | `String` | Formats a string with named arguments from a map. |
| `titleCase(String input, boolean everyWord)` | `String` | Converts a string to title case. |
### Conversion
| Method | Return Type | Description |
|--------|-------------|-------------|
| `romanToInt(String roman)` | `int` | Converts a Roman numeral string to an integer. |
| `intToRoman(int number)` | `String` | Converts an integer to a Roman numeral string. |
### Comparison
| Method | Return Type | Description |
|--------|-------------|-------------|
| `calculateSimilarity(String a, String b)` | `double` | Returns a similarity score (0.0 to 1.0) between two strings. |
---
## Usage
```java
long millis = StringHelper.parseShortTimeStringToMillis("1h30m"); // 5400000
String duration = StringHelper.getTimeDuration(3661); // "1 hour, 1 minute, 1 second"
String shortCode = StringHelper.getShortTimeCode(5400000L); // "1h"
String title = StringHelper.titleCase("hello world", true); // "Hello World"
String roman = StringHelper.intToRoman(14); // "XIV"
int num = StringHelper.romanToInt("XIV"); // 14
double sim = StringHelper.calculateSimilarity("hello", "hallo"); // ~0.8
```
---
## Related Pages
- [[VariableContext]]
- [[MiniMessageHelper]]