configurable timezone
This commit is contained in:
parent
54d7d3bdc1
commit
cb6bde574a
4 changed files with 8 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ public final class BlockFoxPlugin extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
this.saveDefaultConfig();
|
||||||
CommandRouter commandRouter = new CommandRouter(getCommand("blockfox"));
|
CommandRouter commandRouter = new CommandRouter(getCommand("blockfox"));
|
||||||
commandRouter.addCommandMapping(new TestRSSCommand(this), "testrss");
|
commandRouter.addCommandMapping(new TestRSSCommand(this), "testrss");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class TestRSSCommand extends SubCommand {
|
||||||
|
|
||||||
Optional<String> optionalDate = items.getFirst().getPubDate();
|
Optional<String> optionalDate = items.getFirst().getPubDate();
|
||||||
if(optionalDate.isPresent()) {
|
if(optionalDate.isPresent()) {
|
||||||
String time = TimeUtils.convertStringTime(optionalDate.get());
|
String time = TimeUtils.convertStringTime(plugin, optionalDate.get());
|
||||||
MessageUtils.sendSimpleSpecialMessage(player, time, NamedTextColor.GRAY);
|
MessageUtils.sendSimpleSpecialMessage(player, time, NamedTextColor.GRAY);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,20 @@
|
||||||
package de.lunarakai.blockfox.utils;
|
package de.lunarakai.blockfox.utils;
|
||||||
|
|
||||||
|
import de.lunarakai.blockfox.BlockFoxPlugin;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class TimeUtils {
|
public class TimeUtils {
|
||||||
public static String convertStringTime(String time) {
|
public static String convertStringTime(BlockFoxPlugin plugin, String time) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZZZ");
|
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZZZ");
|
||||||
try {
|
try {
|
||||||
Date date = sdf.parse(time);
|
Date date = sdf.parse(time);
|
||||||
|
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
SimpleDateFormat outputFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
outputFormat.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
|
outputFormat.setTimeZone(TimeZone.getTimeZone(plugin.getConfig().getString("common.timezone")));
|
||||||
|
|
||||||
return outputFormat.format(date);
|
return outputFormat.format(date);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
|
|
|
||||||
2
src/main/resources/config.yml
Normal file
2
src/main/resources/config.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
common:
|
||||||
|
timezone: Europe/Berlin
|
||||||
Loading…
Add table
Add a link
Reference in a new issue