本文整理汇总了Java中java.time.ZoneId.getAvailableZoneIds方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneId.getAvailableZoneIds方法的具体用法?Java ZoneId.getAvailableZoneIds怎么用?Java ZoneId.getAvailableZoneIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZoneId
的用法示例。
在下文中一共展示了ZoneId.getAvailableZoneIds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: action
import java.time.ZoneId; //导入方法依赖的package包/类
@Override
public void action(String prefix, String[] args, MessageReceivedEvent event)
{
Set<String> zones = ZoneId.getAvailableZoneIds();
StringBuilder msg = new StringBuilder("**Available options for time zones**\n");
for (String zone : zones)
{
if (msg.length() > 1900)
{
MessageUtilities.sendMsg(msg.toString(), event.getChannel(), null);
msg = new StringBuilder("**continued. . .**\n");
// sleep for a second so as to not get rate limited
try {Thread.sleep(1000);}
catch( Exception ignored ) { }
}
if (args.length == 0)
{
msg.append(" ").append(zone).append("\n");
}
else if (zone.toUpperCase().contains(args[0].toUpperCase()))
{
msg.append(" ").append(zone).append("\n");
}
}
MessageUtilities.sendMsg(msg.toString(), event.getChannel(), null);
}
示例2: parseZone
import java.time.ZoneId; //导入方法依赖的package包/类
/**
* Parses user supplied input for zone information
* Allows for zone names to be inputted without proper capitalization
* @param userInput (String) user input
* @return (ZoneId) zone information as parsed
*/
public static ZoneId parseZone(String userInput)
{
for(String validZone : ZoneId.getAvailableZoneIds())
{
if(validZone.equalsIgnoreCase(userInput))
{
return ZoneId.of(validZone);
}
}
return ZoneId.of(Main.getBotSettingsManager().getTimeZone());
}
示例3: verifyZone
import java.time.ZoneId; //导入方法依赖的package包/类
/**
* Verify that a provided Zone string is valid
* @param arg Zone string
* @return true if valid
*/
public static boolean verifyZone(String arg)
{
for(String validZone : ZoneId.getAvailableZoneIds())
{
if(validZone.equalsIgnoreCase(arg))
{
return true;
}
}
return false;
}
示例4: test_getAvailableGroupIds
import java.time.ZoneId; //导入方法依赖的package包/类
@Test
public void test_getAvailableGroupIds() {
Set<String> zoneIds = ZoneId.getAvailableZoneIds();
assertEquals(zoneIds.contains("Europe/London"), true);
zoneIds.clear();
assertEquals(zoneIds.size(), 0);
Set<String> zoneIds2 = ZoneId.getAvailableZoneIds();
assertEquals(zoneIds2.contains("Europe/London"), true);
}
示例5: test_adjustInto_ZonedDateTime
import java.time.ZoneId; //导入方法依赖的package包/类
@Test
public void test_adjustInto_ZonedDateTime() {
ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
for (String zoneId : ZoneId.getAvailableZoneIds()) {
//Do not change offset of ZonedDateTime after adjustInto()
ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());
OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
assertEquals(base, offsetDateTime_result.getOffset());
}
}