結果

問題 No.652 E869120 and TimeZone
ユーザー YamaKasa
提出日時 2018-09-30 22:17:45
言語 Java
(openjdk 23)
結果
AC  
実行時間 212 ms / 1,000 ms
コード長 1,285 bytes
コンパイル時間 3,127 ms
コンパイル使用メモリ 92,968 KB
実行使用メモリ 57,672 KB
最終ジャッジ日時 2024-06-11 12:28:40
合計ジャッジ時間 10,438 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String h = scan.next();
		String m = scan.next();
		String t = scan.next();
		scan.close();
		int H;
		int M;
		double k;
		if(h.charAt(0) == '0') {
			H = Integer.parseInt(h.substring(1, 2));
		}else {
			H = Integer.parseInt(h.substring(0, 2));
		}
		if(m.charAt(0) == '0') {
			M = Integer.parseInt(m.substring(1, 2));
		}else {
			M = Integer.parseInt(m.substring(0, 2));
		}
		if(t.charAt(4) == '0') {
			k = Double.parseDouble(t.substring(3, t.length()));
		}else {
			k = Double.parseDouble(t.substring(3, t.length()));
		}

		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        Date date = new Date();
        try {
        	String s = H + ":" + M;
        	date = sdf.parse(s);
        }catch(ParseException e) {
            e.printStackTrace();
        }

        int d = (int)Math.round(k * 60) - 540;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.MINUTE, d);
        Date d1 = calendar.getTime();
        System.out.println(sdf.format(d1));
	}
}
0