Here you can find the source of formatTime(final long time)
Parameter | Description |
---|---|
time | Raw time input |
public static String formatTime(final long time)
//package com.java2s; /*/*from ww w .jav a2 s .c o m*/ * This file is part of SpaceBukkit (http://spacebukkit.xereo.net/). * * SpaceBukkit is free software: you can redistribute it and/or modify it under the terms of the * Attribution-NonCommercial-ShareAlike Unported (CC BY-NC-SA) license as published by the Creative * Common organization, either version 3.0 of the license, or (at your option) any later version. * * SpaceBukkit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Attribution-NonCommercial-ShareAlike Unported (CC BY-NC-SA) license for more details. * * You should have received a copy of the Attribution-NonCommercial-ShareAlike Unported (CC BY-NC-SA) * license along with this program. If not, see <http://creativecommons.org/licenses/by-nc-sa/3.0/>. */ public class Main { /** * Formats time from long to a readable String * @param time Raw time input * @return Readable time */ public static String formatTime(final long time) { final int hours = (int) ((time / 1000 + 8) % 24); final int minutes = (int) (60 * (time % 1000) / 1000); return String.format("%02d:%02d (%d:%02d %s)", hours, minutes, hours % 12 == 0 ? 12 : hours % 12, minutes, hours < 12 ? "am" : "pm"); } }