Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6144563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:40:05+00:00 2026-05-23T18:40:05+00:00

I have two function to calculate date and time. public static String getFormattedDate(String time)

  • 0

I have two function to calculate date and time.

  public static String getFormattedDate(String time) {
    long timeUnix = Long.parseLong(time);
    Date myDate = new Date(timeUnix * 1000);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM d yy");
    return simpleDateFormat.format(myDate);
}

  public static String getFormattedTime(String time) {
    long timeUnix = Long.parseLong(time);
    Date myDate = new Date(timeUnix * 1000);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm:ss");
    return simpleDateFormat.format(myDate);
}

I get the correct output from them which I need.

Jul 12 11(date function) and 12:09:45(time function)

How can I calculate days from this and how to set am/pm with this.

I am trying to set time with am/pm if it is today’s date and if it is older than show the day(mon,tue,wed etc.) and if it is more than week old than show “MMM d yy”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:40:06+00:00Added an answer on May 23, 2026 at 6:40 pm

    For am/pm notation:

    SimpleDateFormat dateFormat = new SimpleDateFormat("KK:mm:ss a");
    return dateFormat.format(myDate);
    

    KK is hour in am/pm (0-11), while HH is hour in day (0-23)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have these two functions, public static string[] CharToHex(string str, string prefix, string
I have two functions that calculate the last date of a month entered by
i have created below function to get date difference between two dates.. pleas check
I have two PHP functions to calculate the relation between two texts. They both
I have two constructor : function clsUsagerEmailUserName($nickName, $email) { $this->nickName = $nickName; $this->email =
I have two classes that each need an instance of each other to function.
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
I have two functions in an ActionScript class, they are: private function loaderCompleteHandler(event:Event):void {
I have two begininer programs, both using the 'while' function, one works correctly, and
I have two WIN32 DLL projects in the solution, main.dll should call a function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.