Java tutorial
//package com.java2s; /* * ****************************************************************************** * * Copyright (c) 2015. Shahul Hameed. * * * * Licensed under GNU GENERAL PUBLIC LICENSE; * * you may not use this file except in compliance with the License. * * * * 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.util.concurrent.TimeUnit; public class Main { private static long getCurrentTime(TimeUnit timeUnit) { switch (timeUnit) { case NANOSECONDS: return System.nanoTime(); case MILLISECONDS: return System.currentTimeMillis(); default: return System.currentTimeMillis(); } } }