Skip to main content
added 112 characters in body
Source Link
Poke
  • 3.2k
  • 14
  • 30

Java 7, 138 106 105105 104 bytes

String a(String a){return new java.text.SimpleDateFormat("HHmm""Hmm").format(new java.util.Date("Ja1,0,"+a));}

Try it online!Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

-1 byte thanks to Kevin Cruijssen

Java 7, 138 106 105 bytes

String a(String a){return new java.text.SimpleDateFormat("HHmm").format(new java.util.Date("Ja1,0,"+a));}

Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

Java 7, 138 106 105 104 bytes

String a(String a){return new java.text.SimpleDateFormat("Hmm").format(new java.util.Date("Ja1,0,"+a));}

Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

-1 byte thanks to Kevin Cruijssen

added 10 characters in body
Source Link
Poke
  • 3.2k
  • 14
  • 30

Java 7, 138 106106 105 bytes

String a(String a){return new java.text.SimpleDateFormat("HHmm").format(new java.util.Date("Jan1"Ja1,0,"+a));}

Try it online!Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

Java 7, 138 106 bytes

String a(String a){return new java.text.SimpleDateFormat("HHmm").format(new java.util.Date("Jan1,0,"+a));}

Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

Java 7, 138 106 105 bytes

String a(String a){return new java.text.SimpleDateFormat("HHmm").format(new java.util.Date("Ja1,0,"+a));}

Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

deleted 179 characters in body
Source Link
Poke
  • 3.2k
  • 14
  • 30

Java 7, 138138 106 bytes

import java.text.*;StringString a(String a)throws Exception{return new java.text.SimpleDateFormat("HHmm").format(new SimpleDateFormat("hhmma")java.parseutil.Date(a"Jan1,0,"+a));}

I know this is the most naive approach and you can probably do it shorter with clever string manipulation but this is the first thing that came to mind.Try it online!

Input is not colon delimited and has noa space between the time and the am/pm. Output is not colon delimited.

Java 7, 138 bytes

import java.text.*;String a(String a)throws Exception{return new SimpleDateFormat("HHmm").format(new SimpleDateFormat("hhmma").parse(a));}

I know this is the most naive approach and you can probably do it shorter with clever string manipulation but this is the first thing that came to mind. Input is not colon delimited and has no space between the time and the am/pm. Output is not colon delimited.

Java 7, 138 106 bytes

String a(String a){return new java.text.SimpleDateFormat("HHmm").format(new java.util.Date("Jan1,0,"+a));}

Try it online!

Input is colon delimited and has a space between the time and the am/pm. Output is not colon delimited.

Source Link
Poke
  • 3.2k
  • 14
  • 30
Loading