Java液晶数字字体显示当前时间[通俗易懂]

Java液晶数字字体显示当前时间[通俗易懂]Java液晶数字字体显示当前时间importjava.text.SimpleDateFormat;importjava.util.ArrayList;importjava.util.Date;importjava.util.HashMap;importjava.util.List;importjava.util.Map;/****@authorzdy…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

Java液晶数字字体显示当前时间

在这里插入图片描述
在这里插入图片描述

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 
* @author zdy 
* @version 2019年3月11日16:03:12
*/
public class PrintDate {
private final static String[][] parr = {
{" ","-","-"," "," ","-","-"," "," "," ","-","-"," "," ","-","-"," "},
{"|"," "," ","|","|"," "," ","|",".","|"," "," ","|","|"," "," ","|"},
{" ","-","-"," "," ","-","-"," "," "," ","-","-"," "," ","-","-"," "},
{"|"," "," ","|","|"," "," ","|",".","|"," "," ","|","|"," "," ","|"},
{" ","-","-"," "," ","-","-"," "," "," ","-","-"," "," ","-","-"," "}};
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
while(true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
print(parr);
}
}
});
t.start();
t.join(0);
}
private static void print(String[][] arr) {
Map<Integer,List<Integer>> m =  getDateArr();
for (int i = 0; i < arr.length; i++) {
List<Integer> indexs = m.get(i);
for (int l = 0; l < arr[i].length; l++) {
boolean flag = false;
for (Integer index : indexs) {
if(index == l) {
flag = true;
break;
}
}
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(!flag) {
System.out.print(arr[i][l]);
} else {
System.err.print(arr[i][l]);
}
}
System.out.println();
}
}
private static Map<Integer,List<Integer>> getDateArr(){
Map<Integer,List<Integer>> m = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
String currentTime = sdf.format(new Date());
System.out.println(currentTime);
String[] time = currentTime.split(":");
String[] hour = time[0].split("");
for (int i = 0; i < hour.length; i++) {
Map<Integer, List<Integer>> tmp = getDateArrD(Integer.valueOf(hour[i]), i,0);
if(!tmp.isEmpty()) {
tmp.keySet().forEach(key -> {
List<Integer> list = m.get(key);
if(list ==null || list.size() <= 0) {
m.put(key, tmp.get(key));
} else {
list.addAll(tmp.get(key));
m.put(key, list);
}
});
}
}
String[] minute = time[1].split("");
for (int i = 0; i < minute.length; i++) {
Map<Integer, List<Integer>> tmp = getDateArrD(Integer.valueOf(minute[i]), i+2,1);
if(!tmp.isEmpty()) {
tmp.keySet().forEach(key -> {
List<Integer> list = m.get(key);
if(list ==null || list.size() <= 0) {
m.put(key, tmp.get(key));
} else {
list.addAll(tmp.get(key));
m.put(key, list);
}
});
}
}
return m;
}
private static Map<Integer,List<Integer>> getDateArrD(int num,int index,int n){
Map<Integer,List<Integer>> m = new HashMap<>();
List<Integer> n1 = null;
switch(num) {
default:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(3+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
case 1:
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(3, n1);
return m;
case 2:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(4+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
case 3:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
case 4:
n1 = new ArrayList<>();
n1.add(0+index*4+n);
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(3, n1);
return m;
case 5:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
case 6:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
n1.add(3+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
case 7:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(3, n1);
return m;
case 8:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(3+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
case 9:
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(0, n1);
n1 = new ArrayList<>();
n1.add(0+index*4+n);
n1.add(3+index*4+n);
m.put(1, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(2, n1);
n1 = new ArrayList<>();
n1.add(3+index*4+n);
m.put(3, n1);
n1 = new ArrayList<>();
n1.add(1+index*4+n);
n1.add(2+index*4+n);
m.put(4, n1);
return m;
}
}
}

Jetbrains全家桶1年46,售后保障稳定

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/223014.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • C++能做什么[通俗易懂]

    C++能做什么[通俗易懂]C++Applications2011年6月18日更新这里有一个有关系统、应用程序和库的列表,列表中的全部或者大部分代码用C++编写,当然,该列表并不全面。即使我如何努力,我也不能列举一个含有1000个主要由C++编写的程序列表,但是这里的列表可能包含我听说过程序之中的第1000个。这是一个包括系统、应用程序和库的列表,读者可能熟悉其中的一些,新手可能有个概念C++能做什么,或者我仅仅

  • NLP关键词提取方法总结及实现

    NLP关键词提取方法总结及实现目录一、关键词提取概述二、TF-IDF关键词提取算法及实现三、TextRank关键词提取算法实现四、LDA主题模型关键词提取算法及实现五、Word2Vec词聚类的关键词提取算法及实现六、信息增益关键词提取算法及实现七、互信息关键词提取算法及实现八、卡方检验关键词提取算法及实现九、基于树模型的关键词提取算法及实现十、总结一、关键词提取概述关键词是能够表…

    2022年10月23日
  • pip 安装.whl文件「建议收藏」

    pip 安装.whl文件「建议收藏」参见网址https://www.lfd.uci.edu/~gohlke/pythonlibs/,基本上包含了常用的pythonlib各个版本。下载本机机器上的python使用的对应版本的lib,切到下载位置,使用命令(以安装matplotlib为例):pip install ./matplotlib-2.2.3-cp36-cp36m-win32.whl 即可很快完成安装…

  • 光猫 路由器 ipv6_ipv6光猫设置

    光猫 路由器 ipv6_ipv6光猫设置电信光猫桥接+ML固件路由器实现ipv6网站访问

  • 简介pid参数整定的基本方法_一阶倒立摆的PID

    简介pid参数整定的基本方法_一阶倒立摆的PID0.前言关于PID参数的整定,网上调节的口诀、原则、方法满天飞,但是并没有具体的到步的教程,作为初学者且非自动化相关专业学生有点看不懂、一脸懵逼,走了不少弯路,呕心沥血才调节好,之后才看得懂那些口诀、原则。为了让大家少走弯路,这里将给出圆周倒立摆直立环PID参数整定的具体步骤。多图预警!圆周倒立摆整体图1.PID编程及理解磨刀不误砍材工,是骡子是马,咱先看看,要想调好PI…

  • mysql数据库优化总结

    mysql数据库优化总结

    2021年10月15日

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号