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

相关推荐

  • KTT条件_kkt条件全称

    KTT条件_kkt条件全称上篇文章说了,拉格朗日乘子法,可以在等式约数的条件下,求得某函数f的极大或极小值,但是,等式约束只是不等式约束中的特例,如果我们遇到了不等式约束,该怎么办呢?本片不打算放图了,感觉完全可以接着上一篇继续搞!首先,对于等式约数,我们可以看成我们自变量可以取的点组成的几条线,也就是约束函数在某高度上的等高线。不过约束换成了不等式约束以后,此时约束就可能由“线”变成了面。但是,看上去需要考虑的取值…

    2022年10月21日
  • 京东抢购脚本使用方法+代码更新(超详细)

    最近一段时间,很多人在京东抢购茅台的过程中,由于不会搭建脚本的环境,因此望而却步。因此,特地写了这篇文章,一步一步指导小白如何完成python环境的搭建。注意,本文采用的是最基础的pyharm搭建,具备安装基础的同学可以略过。由于2月1日规格的改变,因此在原来代码基础上进行了部分更新。接下来开始具体阐述搭建环境的过程。1.安装pyharm下载地址:https://www.jetbrains.com/pycharm/这里注意下,windows、mac、linux环境下选择相对应的版本,本文以w

  • Lucene中AttributeSource作为TokenStream父类的原因

    Lucene中AttributeSource作为TokenStream父类的原因lucene3.0lucene中有如下的类层次:org.apache.lucene.util.AttributeSourceorg.apache.lucene.analysis.TokenStream(implementsjava.io.Closeable)org.apache.lucene.analysis.NumericTokenStreamorg.apache…

  • puppet的refresh与refreshonly参数作用

    puppet的refresh与refreshonly参数作用

  • SPPnet 笔记

    SPPnet 笔记ECCV2014的文章,后来又扩展成了TPAMI整体的先后次序:RCNN(CVPR2014)->SPPnet(ECCV2014)->FastRCNN(ICCV2015)->FasterRCNN(NIPS2015)现有的深度卷积网络需要固定大小的输入图片(比如224×224224\times224224×224),这个要求人工设计的痕迹过于明显,并且可能会降低一…

  • iphone越狱pp助手源_pp助手越狱版源地址

    iphone越狱pp助手源_pp助手越狱版源地址在为方便大家查看核桃同学分享的每日文章,建议小伙伴们【置顶我们】的公众号哦!进入【米乐科技】公众号,点击右上角打开设置界面,再次右上角选择【置顶/星标】,这样就可以啦!苹果越狱教程篇其实在编辑这篇文章的时候,核桃同学还在纠结是分享实用软件呢,还是先分享玩机技巧。恰好有小伙伴留言说想了解越狱只是,于是乎本文就诞生了。在往期的发布中,苹果机的资源分享的较少。主要是因为苹果手机在官家IOS系统…

    2022年10月29日

发表回复

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

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