目录

1、Date类

2、Calendar类


java.util.Date日期类
java.text.SimpleDateFormat日期转换类

SimpleDateFormat:实现String和Date之间的转换

1、 日期转字符串

import java.io.*;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)1e4 + 10;static math math_bag = new math();static int fa[] = new int[N];public static void main(String[] args ) throws IOException, ParseException{// 创建日期对象(日期、时间)Date d = new Date();// 创建日期格式对象SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");// 日期转换为字符串String str = s.format(d);pw.println(str);pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while(!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next()); }static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class math
{int gcd(int a,int b){if(b == 0)  return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i)  a.add(n / i);  // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况  ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++)  if (n % i == 0) return false;return true;}
}class PII implements Comparable<PII>
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}public int compareTo(PII a){if(this.x-a.x != 0)return this.x-a.x;  //按x升序排序else return this.y-a.y;  //如果x相同,按y升序排序}
}class Edge
{int a,b,c;public Edge(int a ,int b, int c){this.a = a;this.b = b;this.c = c;}
}

2、字符串转换为日期(用的少)

import java.io.*;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)1e4 + 10;static math math_bag = new math();static int fa[] = new int[N];public static void main(String[] args ) throws IOException, ParseException{String t = "2023年12月20日";SimpleDateFormat sd = new SimpleDateFormat("yyyy年MM月dd日"); // 需要和上边的字符串的日期格式相同Date e = sd.parse(t);pw.println(e);pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while(!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next()); }static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class math
{int gcd(int a,int b){if(b == 0)  return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i)  a.add(n / i);  // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况  ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++)  if (n % i == 0) return false;return true;}
}class PII implements Comparable<PII>
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}public int compareTo(PII a){if(this.x-a.x != 0)return this.x-a.x;  //按x升序排序else return this.y-a.y;  //如果x相同,按y升序排序}
}class Edge
{int a,b,c;public Edge(int a ,int b, int c){this.a = a;this.b = b;this.c = c;}
}

1、Date类

说明:Date日期类通常用于日期的计算
说明:Date中存储的是距离一个历史时间点(1970年)的毫秒数。

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"):创造一个日期格式,给Date来用

Date date = simpleDateFormat.parse("2000-1-1"):上面创建的日期格式后就可以给Date类型赋值了

long t = date.getTime():获取时间,单位是毫秒

import java.io.*;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)1e4 + 10;static math math_bag = new math();static int fa[] = new int[N];public static void main(String[] args ) throws IOException, ParseException{Date d = new Date();long t = d.getTime();pw.println(t);pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while(!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next()); }static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class math
{int gcd(int a,int b){if(b == 0)  return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i)  a.add(n / i);  // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况  ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++)  if (n % i == 0) return false;return true;}
}class PII implements Comparable<PII>
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}public int compareTo(PII a){if(this.x-a.x != 0)return this.x-a.x;  //按x升序排序else return this.y-a.y;  //如果x相同,按y升序排序}
}class Edge
{int a,b,c;public Edge(int a ,int b, int c){this.a = a;this.b = b;this.c = c;}
}

计算两天后的日期:

import java.io.*;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)1e4 + 10;static math math_bag = new math();static int fa[] = new int[N];public static void main(String[] args ) throws IOException, ParseException{// 2天后的日期Date date = new Date();date.setTime(date.getTime() + 2L * 24 * 60 * 60 * 1000);SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");pw.println(s.format(date));pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while(!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next()); }static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class math
{int gcd(int a,int b){if(b == 0)  return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i)  a.add(n / i);  // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况  ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++)  if (n % i == 0) return false;return true;}
}class PII implements Comparable<PII>
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}public int compareTo(PII a){if(this.x-a.x != 0)return this.x-a.x;  //按x升序排序else return this.y-a.y;  //如果x相同,按y升序排序}
}class Edge
{int a,b,c;public Edge(int a ,int b, int c){this.a = a;this.b = b;this.c = c;}
}

Date的使用例子:

标题:第几天

2000年的1月1日,是那一年的第1天。
那么,2000年的5月4日,是那一年的第几天?

注意:需要提交的是一个整数,不要填写任何多余内容。

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)500 + 10;static long a[][] = new long[N][N];static long s[][] = new long[N][N];public static void main(String[] args ) throws IOException, ParseException{SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");Date date1 = simpleDateFormat.parse("2000-1-1");Date date2 = simpleDateFormat.parse("2000-5-4");long t1 = date1.getTime();long t2 = date2.getTime();pw.println((t2 - t1) / (24*60*60*1000) + 1);pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException  { return reader.readLine(); }static String next() throws IOException{while (!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException  { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException  { return Long.parseLong(next());}static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class PII
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}
}

2、Calendar类

创建Calendar对象的API:

getInstance()

修改时间的API:

set():可以改变年、月、日、星期几

add():add方法会产生其他相关时间属性的连动变化

实战:

//set()方法:两个参数【设置的项,设置的值】
calendar.set(Calendar.YEAR, year); // 存年
calendar.set(Calendar.MONTH, 11); // 存月,MONTH字段是从0月开始计数的,与数组类似,所以要想存12月,传参数11,
calendar.set(Calendar.DAY_OF_MONTH, 31); //设置日期  31号

calendar的使用例子:

1、世纪末的星期

标题: 世纪末的星期

曾有邪教称1999年12月31日是世界末日。当然该谣言已经不攻自破。

还有人称今后的某个世纪末的12月31日,如果是星期一则会....

有趣的是,任何一个世纪末的年份的12月31日都不可能是星期一!!

于是,“谣言制造商”又修改为星期日......

1999年的12月31日是星期五,请问:未来哪一个离我们最近的一个世纪末年(即xx99年)的12月31日正好是星期天(即星期日)?

请回答该年份(只写这个4位整数,不要写12月31等多余信息)

答案:2299

代码:(此题使用java中的日历类)

import javax.print.DocFlavor;
import java.io.*;
import java.math.BigInteger;
import java.util.*;public class Main
{static Scanner sc = new Scanner(System.in);static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int) 1e5 + 10;static PII a[] = new PII[N];static Set<Integer> set = new HashSet<>();public static void main(String[] args) throws IOException{Calendar calendar = Calendar.getInstance(); //获取Calendar类的实例,这样才能用for(int year=1999;year<10000;year+=100)//题目要求必须是xx99年 也就是每次加一百年{//set()方法:两个参数【设置的项,设置的值】calendar.set(Calendar.YEAR, year); // 存年calendar.set(Calendar.MONTH, 11); // 存月,MONTH字段是从0月开始计数的,与数组类似,所以要想存12月,传参数11,calendar.set(Calendar.DAY_OF_MONTH, 31); //设置日期  31号if (calendar.get(Calendar.DAY_OF_WEEK) == 1)  //get()方法获取值; DAY_OF_WEEK一周中的第几天,星期日是第一天{ // 国外星期天对应的是1 星期一对应的是2 以此类推pw.println(year);break;}}pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while(!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next()); }static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class PII implements Comparable<PII>
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}public int compareTo(PII a){if(this.x-a.x != 0)return this.x-a.x;  //按x升序排序else return this.y-a.y;  //如果x相同,按y升序排序}
}class Edge
{int a,b,c;public Edge(int a ,int b, int c){this.a = a;this.b = b;this.c = c;}
}

2、 跑步锻炼

AC代码1:()

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)2e5 + 10;public static void main(String[] args ) throws IOException{int res = 0;Calendar c = Calendar.getInstance(); //建一个Calendarc.set(2000,0,1); // 把开始时间丢到Calendar里面去,注意月从0开始while (true){int day_of_month = c.get(Calendar.DAY_OF_MONTH); // 得到该天是该月的第几天(得到该时间的日)int daya_of_week = c.get(Calendar.DAY_OF_WEEK); // 得到该天是该周的第几天int year = c.get(Calendar.YEAR); //得到该时间的年int month = c.get(Calendar.MONTH); // 得到该时间的月if(day_of_month == 1 || daya_of_week == 2)  res += 2;else  res += 1;if(year == 2020 && month == 9 && day_of_month==1){pw.println(res);pw.flush();return;}c.add(Calendar.DATE,1); //时间增加一天}}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while(!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next()); }static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class math
{int gcd(int a,int b){if(b == 0)  return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i)  a.add(n / i);  // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况  ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++)  if (n % i == 0) return false;return true;}
}class PII implements Comparable<PII>
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}public int compareTo(PII a){if(this.x-a.x != 0)return this.x-a.x;  //按x升序排序else return this.y-a.y;  //如果x相同,按y升序排序}
}class Edge
{int a,b,c;public Edge(int a ,int b, int c){this.a = a;this.b = b;this.c = c;}
}class Line implements Comparable<Line>
{double k; // 斜率double b; // 截距public Line(double k, double b){this.k = k;this.b = b;}@Overridepublic int compareTo(Line o){if (this.k > o.k) return 1;if (this.k == o.k){if (this.b > o.b) return 1;return -1;}return -1;}
}class mqm
{int fa[] = new int[1005];void init(){for(int i = 1 ; i <= 1000 ; i ++)  fa[i] = i;}void merge(int x, int y) { fa[find(x)] = find(y); }int find(int x){if(x != fa[x])  fa[x] = find(fa[x]);return fa[x];}boolean query(int x, int y) { return find(x) == find(y); }
}

AC代码2:(LocalDate真的优美!!!)

import java.time.LocalDate;public class Main
{public static void main(String[] args) {LocalDate startTime = LocalDate.of(2000, 1, 1); // 设置开始时间LocalDate endtTime = LocalDate.of(2020, 10, 1); // 设置结束时间int allKM = 0;while(!startTime.isAfter(endtTime)) // 开始时间不等于最终时间{if(startTime.getDayOfWeek().getValue() == 1 || startTime.getDayOfMonth() == 1)  allKM += 2; // 周一或者每个月的一号,跑两千米else  allKM += 1; startTime = startTime.plusDays(1); // 时间+1}System.out.println(allKM); // 输出总公里数}
}

3、

代码:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)3000 + 10;public static void main(String[] args ) throws IOException, ParseException{Calendar calendar = Calendar.getInstance();calendar.set(2022,0,1);int cnt = 0;while(true){int year = calendar.get(Calendar.YEAR);int month = calendar.get(Calendar.MONTH);int day_of_month = calendar.get(Calendar.DAY_OF_MONTH);int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);if(day_of_week == 7 || day_of_week == 1 || day_of_month == 1 || day_of_month == 11 || day_of_month == 21 || day_of_month == 31)  cnt ++;if(year == 2022 && month == 11 && day_of_month == 31){pw.println(cnt);pw.flush();return;}calendar.add(Calendar.DATE,1);}//         Calendar calendar = Calendar.getInstance();
//
//         calendar.set(2000,0,1);
//         int year = calendar.get(Calendar.YEAR);
//         int month = calendar.get(Calendar.MONTH);
//         int day_of_month = calendar.get(Calendar.DAY_OF_MONTH);
//         int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
//
//         pw.println(year);
//         pw.println(month);
//         pw.println(day_of_month);
//         pw.println(day_of_week);
//         pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException  { return reader.readLine(); }static String next() throws IOException{while (!tokenizer.hasMoreTokens())  tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException  { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException  { return Long.parseLong(next());}static BigInteger nextBigInteger() throws IOException { return new BigInteger(rd.nextLine()); }
}class PII
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}
}

JAVA-日期类(Date、SimpleDateFormat)相关推荐

  1. 新手小白学JAVA 日期类Date SimpleDateFormat Calendar

    1. Date日期类 类 Date 表示一个特定的瞬间,精确到毫秒 1.1 Date的构造函数 Date() 分配一个 Date 对象,以表示分配它的时间(精确到毫秒) Date(long date) ...

  2. java 日期类Date插入mysql数据库时间总是比参数时间少一天

    问题发生: 插入日期比预想的少了一天,查看java 中执行的sql INSERT INTO t3b_msg (send_dt) values(str_to_date('2019 - 10 - 18', ...

  3. Java日期类 util.Date sql.Date Calendar LocalDateTime 格式化 DateFormat DateTimeFormatter

    java 日期类 java.util.Date Date有两个附加功能. 它允许将日期解释为年,月,日,小时,分钟和第二个值. 它还允许格式化和解析日期字符串. 但这些功能的API不适合国际化. 从J ...

  4. java定义一个日期类 包括年 月 日_【说明】 设计一个日期类Date包括年、月、日等私有数据成员。要求实现日期..._考试资料网...

    填空题[说明] 设计一个日期类Date包括年.月.日等私有数据成员.要求实现日期的基本运算,如某日期加上天数.某日期减去天数.两日期相差的天数等. 在Date类中设计如下重载运算符函数: Date o ...

  5. java日期类的计算问题_java日期计算(Calendar类)

    昨天学了java日期的格式器,主要是用SimpleDateFormat进行格式化.解析.但这还仅停留在日期的查看(调整显示格式)阶段,更重要的是日期的操作.今天继续学习,记录如下: 今天主要学习的日期 ...

  6. python设计一个date类数据成员有年月日_设计一个日期类Date,包括年、月、日等私有成员。要求实现日期的基本运算,例如某日期加上天数或减去天数...

    /*设计一个日期类Date,包括年.月.日等私有成员.要求实现日期的基本运算,例如某日期加上天数或减去天数 ,两日期相减的天数等. 实现要求: 实现运算符加与减的重载 设计一个日期类Date,包括年. ...

  7. (C++)设计一个日期类Date,包括年、月、日等私有数据成员。要求实现日期的基本运算,包括某日期加上指定天数、某日期减去指定天数、两个日期相差的天数等。

    C++面向对象程序设计课后作业第239页第5题 题目要求:设计一个日期类Date,包括年.月.日等私有数据成员.要求实现日期的基本运算,包括某日期加上指定天数.某日期减去指定天数.两个日期相差的天数等 ...

  8. 设计一个日期类Date

    //用C++++设计一个日期类Date,该类用于表示日期值(年.月.日). //要求除了能够通过相应的成员函数设置和获取日期值外,还能够实现将日期加一天的操作. #include<iostrea ...

  9. 日期类Date控制台应用程序设计C#

    日期类Date控制台应用程序设计 小咸鱼终于又准备敲代码辽呜呜,什么王者荣耀,耽误我学习hhh 实验要求 实验要求:写出类 Date 的定义代码,含有如图所示的 3 个字段及 4 个方法. 实验目的 ...

  10. java怎么创建日期类_java中的日期类Date

    一.Java中的日期概述 日期在Java中是一块非常复杂的内容,对于一个日期在不同的语言国别环境中,日期的国际化,日期和时间之间的转换,日期的加减运算,日期的展示格式都是非常复杂的问题. 在Java中 ...

最新文章

  1. 详解微信域名防封的方法以及检测等工具的技术原理
  2. 【Python小脚本】实现王者农药自动刷金币啦~啦啦啦走跟我一起组队~
  3. linux学习笔记-10.解压与压缩
  4. java多线程详细讲解_Java多线程例子讲解
  5. 清华姚班毕业生不配自信?张昆玮在豆瓣征女友,却被网友群嘲......
  6. [转载]敏捷开发之Scrum扫盲篇
  7. 开源软件、开源硬件、……开源餐馆来了
  8. Springboot整合log4j2日志全解
  9. mysql学习day05—子查询 / CASH语句 / 连接查询
  10. Android Realm数据库
  11. iOS开发之国际化(二)
  12. route命令(详细)
  13. fork函数与execve函数
  14. 验证集精度高于训练集精度的原因分析
  15. stdafx.h作用以及include中为何iostream必须放在stdafx.h之后?
  16. NOIP中的数学--第6课 排列与组合
  17. linux skb_buf大小,linux网络 skb_buff
  18. Vue3中关于getCurrentInstance的大坑
  19. dedecms 织梦后台系统配置参数空白的解决方法
  20. 打开计算机桌面上没有跑哪里去了,Win8.1我的电脑图标跑哪去了怎么放桌面

热门文章

  1. 浅谈Marlin2.0
  2. Use Ant implementing Continous Integration.
  3. 6 模型的属性与功能
  4. 通过阿里云或清华镜像站安装tensorflow2.0
  5. 最新解决百度网盘不限速方法
  6. 记录配置Jupyter kernels
  7. 计算机ctrl加什么作用,计算机中快捷键ctrl加什么是返回上一步
  8. 【FreeRTOS】FreeRTOS学习笔记(3)— FreeRTOS任务与协程
  9. 记一次企业邮官网SEO优化
  10. 苹果手机软件闪退怎么解决_LOL手游卡顿闪退怎么办-卡顿闪退解决方法解析