Here you can find the source of getParentUnit(TimeUnit unit)
public static TimeUnit getParentUnit(TimeUnit unit)
//package com.java2s; /**// w ww.j a v a 2 s.co m * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import java.util.concurrent.TimeUnit; public class Main { public static TimeUnit getParentUnit(TimeUnit unit) { TimeUnit result = null; switch (unit) { case HOURS: result = TimeUnit.DAYS; break; case MINUTES: result = TimeUnit.HOURS; break; case SECONDS: result = TimeUnit.MINUTES; break; case MILLISECONDS: result = TimeUnit.SECONDS; break; case MICROSECONDS: result = TimeUnit.MILLISECONDS; break; case NANOSECONDS: result = TimeUnit.MICROSECONDS; break; default: break; } return result; } }