我希望从当前日期开始7天。我不确定需要什么代码。
我必须找到当前日期的代码是:
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Calendar cal = Calendar.getInstance();
String date = dateFormat.format(cal.getTime());
答案 0 :(得分:0)
我在堆栈溢出时发现了以下代码.... How can I increment a date by one day in Java?
from Tkinter import *
import math
import time
root = Tk()
root.geometry("800x480")
root.configure(background='darkgrey')
content = Frame(root,)
#Dimensions of Window
w = 800
h = 480
#Get Angle
file_angle = open("current_angle.txt")
#read file and remove "/n" from the end of the string
string_angle = ((file_angle.read())[:-2])
#Convert string to a number
read_angle = float(string_angle)
if read_angle > 90 or read_angle <-90:
deg_angle = read_angle - 180
else:
deg_angle = read_angle
angle = math.radians(deg_angle)
swath_width = w / 5
if deg_angle > -90 and deg_angle < 90:
#Center Line
centertopx = (w/2) + ((h / 1.5) * math.tan(angle))
centertopy = 0
centerbottomx = (w/2) + ((h - (h / 1.5)) * math.tan(-1 * angle))
centerbottomy = h
if deg_angle == 90 or deg_angle == -90:
centertopx = 0
centertopy = h / 2
centerbottomx = w
centerbottomy = h / 2
#Create Guidance Map
livemap = Canvas(root, width=w, height=h)
#Outline of map
livemap.create_rectangle(0,0,w,h, outline="black", width=5, fill="#9E9E9E")
#Drawing lines
livemap.create_line(centertopx, centertopy, centerbottomx, centerbottomy, fill="red", width=4)
#stationary parts of map
#Triangle that represents vehicle
livemap.create_polygon(
((w/2)-(w * 0.04)),((h / 1.5)+(h * 0.1)),((w/2)+(w * 0.04)),((h / 1.5)+(h * 0.1)),(w/2),(h / 1.5),
outline="black", fill="darkorange", width=2)
livemap.create_line((w/2),((h / 1.5)+(h*0.07)),(w/2),(h / 1.5),fill="black", width=2)
livemap.create_polygon(((w/2)-(w * 0.04)),((h / 1.5)+(h * 0.1)),((w/2)+(w * 0.04)),((h / 1.5)+(h * 0.1)),(w/2),((h / 1.5)+(h*0.07)),
outline="black", fill="darkorange", width=2)
#Put canvas into window
livemap.grid(column=0, row=0, columnspan=4, rowspan=4)
root.mainloop()
答案 1 :(得分:-2)
LocalDateTime.now().plusDays(7)
https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html