Horje
java convert am pm to 24 hour Code Example
java convert am pm to 24 hour
String result =                                       // Text representing the value of our date-time object.
    LocalTime.parse(                                  // Class representing a time-of-day value without a date and without a time zone.
        "03:30 PM" ,                                  // Your `String` input text.
        DateTimeFormatter.ofPattern(                  // Define a formatting pattern to match your input text.
            "hh:mm a" ,
            Locale.US                                 // `Locale` determines the human language and cultural norms used in localization. Needed here to translate the `AM` & `PM` value.
        )                                             // Returns a `DateTimeFormatter` object.
    )                                                 // Return a `LocalTime` object.
    .format( DateTimeFormatter.ofPattern("HH:mm") )   // Generate text in a specific format. Returns a `String` object.
;
java convert am pm to 24 hour
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
   public static void main(String [] args) throws Exception {
       SimpleDateFormat displayFormat = new SimpleDateFormat("HH:mm");
       SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
       Date date = parseFormat.parse("10:30 PM");
       System.out.println(parseFormat.format(date) + " = " + displayFormat.format(date));
   }
}




Java

Related
Selenium TestNG delay before actions Code Example Selenium TestNG delay before actions Code Example
How do I retrieve editors registered for a certain file extension in Eclipse? Code Example How do I retrieve editors registered for a certain file extension in Eclipse? Code Example
java set get all not containing Code Example java set get all not containing Code Example
java use parent method Code Example java use parent method Code Example
Simple way to find if two different lists contain exactly the same elements? Code Example Simple way to find if two different lists contain exactly the same elements? Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8