func (c *callImpl) Timestamp() time.Time { env, freeFunc := jutil.GetEnv() defer freeFunc() jTime, err := jutil.CallObjectMethod(env, c.jCall, "timestamp", nil, jutil.DateTimeSign) if err != nil { log.Println("Couldn't call Java timestamp method: ", err) return time.Time{} } t, err := jutil.GoTime(env, jTime) if err != nil { log.Println("Couldn't convert Java time to Go: ", err) return time.Time{} } return t }
//export Java_io_v_v23_context_VContext_nativeWithDeadline func Java_io_v_v23_context_VContext_nativeWithDeadline(jenv *C.JNIEnv, jVContext C.jobject, goRef C.jlong, jDeadline C.jobject) C.jobject { env := jutil.Env(uintptr(unsafe.Pointer(jenv))) deadline, err := jutil.GoTime(env, jutil.Object(uintptr(unsafe.Pointer(jDeadline)))) if err != nil { jutil.JThrowV(env, err) return nil } ctx, cancelFunc := context.WithDeadline((*context.T)(jutil.GoRefValue(jutil.Ref(goRef))), deadline) jCtx, err := JavaContext(env, ctx, cancelFunc) if err != nil { jutil.JThrowV(env, err) return nil } return C.jobject(unsafe.Pointer(jCtx)) }