Created
January 30, 2018 06:28
-
-
Save dmikurube/770c66ca2e6ff56f06d9deb1900badec to your computer and use it in GitHub Desktop.
This file contains hidden or 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.Instant; | |
import java.time.ZonedDateTime; | |
import java.time.ZoneId; | |
import java.util.Calendar; | |
import java.util.Locale; | |
import org.joda.time.DateTimeZone; | |
public class AncientDays { | |
public static void main(String[] args) { | |
final ZonedDateTime zoned = ZonedDateTime.of(1000, 1, 1, 0, 0, 0, 0, ZoneId.of("Asia/Tokyo")); | |
final Instant instant = zoned.toInstant(); | |
System.out.println(instant.getEpochSecond()); | |
final Calendar cal = Calendar.getInstance(DateTimeZone.forID("Asia/Tokyo").toTimeZone(), Locale.ENGLISH); | |
cal.setTimeInMillis(instant.getEpochSecond() * 1000L); | |
System.out.println(String.format(Locale.ENGLISH, "%02d-%02d-%02d", | |
cal.get(Calendar.YEAR), | |
cal.get(Calendar.MONTH) + 1, | |
cal.get(Calendar.DAY_OF_MONTH))); | |
} | |
} |
This file contains hidden or 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
apply plugin: 'java' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'joda-time:joda-time:2.9.2' | |
} | |
sourceSets { | |
main { | |
java { | |
srcDir '.' | |
} | |
} | |
} | |
task run(type: JavaExec) { | |
main = project.hasProperty('main') ? project.getProperty('main') : 'AncientDays' | |
classpath = sourceSets.main.runtimeClasspath | |
} |
Author
dmikurube
commented
Jan 30, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment