Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { private static void setAlarm(Calendar calendar, String sTime) { String speech[] = sTime.split(" "); String time = speech[0]; String timeParts[] = time.split(":"); int hour = Integer.parseInt(timeParts[0]); int minute = Integer.parseInt(timeParts[1]); String ampm = speech[1].toUpperCase(); if (ampm.startsWith("P")) { hour += 12; } calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); } }