Easiest way to get it by using date pattern – h:mm a
, where
- h – Hour in am/pm (1-12)
- m – Minute in hour
- a – Am/pm marker
Code snippet :
DateFormat dateFormat = new SimpleDateFormat("hh:mm a");
More Related Contents:
- Change date format in a Java string
- Java SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z'”) gives timezone as IST
- java.util.Date format conversion yyyy-mm-dd to mm-dd-yyyy
- How to convert a String to a Date using SimpleDateFormat?
- how to parse output of new Date().toString()
- “Java DateFormat is not threadsafe” what does this leads to?
- How to format Joda-Time DateTime to only mm/dd/yyyy?
- Java Time Zone When Parsing DateFormat
- How to get Date in the same format as String [duplicate]
- How to convert a letter to an another letter in Java [duplicate]
- Conditionally ignoring tests in JUnit 4
- Which Java Collection should I use?
- Java: Syntax and meaning behind “[B@1ef9157”? Binary/Address?
- Android ListView headers
- Why start an ArrayList with an initial capacity?
- Jackson serialization: ignore empty values (or null)
- Is there an equivalent of java.util.regex for “glob” type patterns?
- Composing Swing Components: How do I add the ability to add ActionListeners?
- Automatic cookie handling with OkHttp 3
- Including jar files in class path
- Why does appending “” to a String save memory?
- Will Java Final variables have default values?
- Stream video in Java
- Is it possible to write swap method in Java? [duplicate]
- org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection Selenium ChromeDriver and Chrome v111
- Convert Uri to String and String to Uri
- Handling unconventional source directory for a web project in maven
- Why does post-increment work on wrapper classes
- Gradle task – pass arguments to Java application
- How do I determine if a class extends another class in Java?