Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static String getDate(int hour, int min) {
        Date d = new Date();
        Calendar now = Calendar.getInstance();
        now.setTime(d);
        now.set(Calendar.HOUR, now.get(Calendar.HOUR) + hour);
        now.set(Calendar.MINUTE, now.get(Calendar.MINUTE) + min);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm");

        return sdf.format(now.getTime());
    }
}