本文整理匯總了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());
}
}