Java Long Number to Time getTime(long time, boolean getTimeOnly, boolean fileSystemSafe)

Here you can find the source of getTime(long time, boolean getTimeOnly, boolean fileSystemSafe)

Description

get Time

License

Open Source License

Parameter

Parameter Description
time The time to convert
getTimeOnly Whether or not the result should exclude the date
fileSystemSafe Whether or not the date should be file system safe(does nothing if the date is excluded)

Return

The result

Declaration

public static String getTime(long time, boolean getTimeOnly, boolean fileSystemSafe) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /** @param time The time to convert
     * @param getTimeOnly Whether or not the result should exclude the date
     * @return The result *//*from   ww  w  .  ja v  a 2  s .  c  o m*/
    public static String getTime(long time, boolean getTimeOnly) {
        return getTime(time, getTimeOnly, false);
    }

    /** @param time The time to convert
     * @param getTimeOnly Whether or not the result should exclude the date
     * @param fileSystemSafe Whether or not the date should be file system
     *            safe(does nothing if the date is excluded)
     * @return The result */
    public static String getTime(long time, boolean getTimeOnly, boolean fileSystemSafe) {
        return new SimpleDateFormat(
                getTimeOnly ? "HH-mm-ss" : fileSystemSafe ? "MM-dd-yyyy_HH.mm.ss" : "MM/dd/yyyy'\t'h:mm:ss a")
                        .format(new Date(time));
    }
}

Related

  1. getSpeedString(long castTime, long bytes)
  2. getStrDateForLong(long time)
  3. getTextDate(long timeInMs)
  4. getTime(long nanos)
  5. getTime(Long time)
  6. getTimeFromLong(long diff)
  7. getTimeFromLong(long diff)
  8. getTimeLong()
  9. getTimeOf12(long time)