- package acm;
- import java.io.UnsupportedEncodingException;
- import java.math.*;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws ParseException, UnsupportedEncodingException {
- Scanner reader = new Scanner(System.in);
- String str = reader.nextLine();
- SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- java.util.Date time = format1.parse(str);
- String op;
- op = reader.next();
- int k=0;
- k = reader.nextInt();
- long afterTime =0;
- // if(op.charAt(0)=='H')
- // {
- // System.out.println("2018年11月10日 星期六 11时17分1秒");
- // }
- // else
- // {
- // System.out.println("2018年11月12日 星期一 9时17分1秒");
- // }
- if(op.charAt(0)=='H')
- {
- afterTime=(time.getTime()/1000)+60*60*k;}
- else
- {
- afterTime=(time.getTime()/1000)+60*60*24*k;
- }
- time.setTime(afterTime*1000);
- SimpleDateFormat format2=new SimpleDateFormat("y年M月d日 E H时m分s秒");
- str = format2.format(time);
- // System.out.println(str);
- byte[] utf8 = str.getBytes("UTF-8");
- String gg = new String(utf8, "UTF-8");
- System.out.println(gg);
- }
- }
JAVA
From axuhongbo, 3 Years ago, written in Plain Text, viewed 302 times.
URL http://axuhongbo.top/paste/view/a56fa4f5
Embed
Download Paste or View Raw
— Expand Paste to full width of browser