Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Java acquires random source code snippets

Shulou Source: shulou.com Published: 2022-06-01 03:24:39 10月05日 Update

Make a record of some important content in the process of writing content. The following information is about java obtaining random time fragments.

import java.text.parseexception;

import java.text.simpledateformat;import java.util.date;public class getrandomtiem {public static void main(string []args){simpledateformat format = new simpledateformat("hh:mm:ss");date randomdate=randomdate("00:00:00","24:59:59");string randomdats="shi"+randomdate.gethours()+"f"+randomdate.getminutes()+"m"+randomdate.getseconds();system.out.println(randomdats);}private static date randomdate(string begindate,string enddate ){try {simpledateformat format = new simpledateformat("hh:mm:ss");if(start.gettime() >= end.gettime()){return null;}long date = random(start.gettime(),end.gettime());return new date(date);} catch (exception e) {e.printstacktrace();}return null;}private static long random(long begin,long end){if(rtn == begin || rtn == end){return random(begin,end);}return rtn;}}

Tags: Content time fragments importance data process source code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple Docker MySQL Huawei