Closed kariya-mitsuru closed 3 years ago
Please see the sample code and its output below.
import java.time.LocalTime; import org.graalvm.polyglot.Context; public class Python2JavaTime { public static void main(String[] args) { try (Context c = Context.newBuilder("python").allowAllAccess(true).build()) { LocalTime t = c.eval("python", "from datetime import time\n" + "t = time(hour=1, minute=2, second=3, microsecond=456789)\n" + "print(t)\n" + "t\n" ).asTime(); System.out.println(t); } } }
GraalPython's output(commit 77321cc8e & CE 20.3.0):
01:02:03.456789 01:02:03.000456789
It should output two 01:02:03.456789.
01:02:03.456789
Note that the datetime.time of Python has a microsecond field but the java.time.LocalTime of Java has a nanosecond field.
datetime.time
java.time.LocalTime
Please see the sample code and its output below.
GraalPython's output(commit 77321cc8e & CE 20.3.0):
It should output two
01:02:03.456789
.Note that the
datetime.time
of Python has a microsecond field but thejava.time.LocalTime
of Java has a nanosecond field.