Here you can find the source of toLong(java.util.Date v)
public static long toLong(java.util.Date v)
//package com.java2s; /*// w ww . jav a 2s. co m * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.sql.Timestamp; import java.util.TimeZone; public class Main { private static final TimeZone LOCAL_TZ = TimeZone.getDefault(); public static long toLong(java.util.Date v) { return toLong(v, LOCAL_TZ); } /** Converts the Java type used for UDF parameters of SQL TIMESTAMP type * ({@link java.sql.Timestamp}) to internal representation (long). * * <p>Converse of {@link #internalToTimestamp(long)}. */ public static long toLong(Timestamp v) { return toLong(v, LOCAL_TZ); } public static long toLong(java.util.Date v, TimeZone timeZone) { long time = v.getTime(); return time + (long) timeZone.getOffset(time); } }