Created
January 31, 2016 15:44
-
-
Save dangnhdev/ac45c4b436d181055519 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public interface TimeClient { | |
void setTime(int hour, int minute, int second); | |
void setDate(int day, int month, int year); | |
void setDateAndTime(int day, int month, int year, | |
int hour, int minute, int second); | |
LocalDateTime getLocalDateTime(); | |
static ZoneId getZoneId (String zoneString) { | |
try { | |
return ZoneId.of(zoneString); | |
} catch (DateTimeException e) { | |
System.err.println("Invalid time zone: " + zoneString + | |
"; using default time zone instead."); | |
return ZoneId.systemDefault(); | |
} | |
} | |
default ZonedDateTime getZonedDateTime(String zoneString) { | |
return ZonedDateTime.of(getLocalDateTime(), getZoneId(zoneString)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment