Removing Timezone from XMLGregorianCalendar

本文提供了一个使用 Java 的 XMLGregorianCalendar 类来创建日期实例并去除时间区域标记或时间信息的示例。通过设置 timezone 和 time 属性为 FIELD_UNDEFINED 来实现这一目的。
Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

 

1、去掉時間之後的“Z”或者修改時區

 1 package Package0809;
 2 
 3 import javax.xml.datatype.DatatypeConfigurationException;
 4 import javax.xml.datatype.DatatypeConstants;
 5 import javax.xml.datatype.DatatypeFactory;
 6 import java.util.Date;
 7 import java.util.GregorianCalendar;
 8 /**
 9  * @author Allen.Lv
10  * @version 1.0
11  * date-time: 2018/8/9-16:53
12  * desc: Create Successful!
13  **/
14 public class XMLGregorianCalendar {
15 
16     public static void main(String[] args) {
17         javax.xml.datatype.XMLGregorianCalendar xmlDate = null;
18         GregorianCalendar gc = new GregorianCalendar();
19         gc.setTime(new Date());
20 
21         try {
22             xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
23             System.out.println("xmlDate-----:"+xmlDate.toString());
24             //To Remove TimeZone or "Z"
25             xmlDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
26             System.out.println("Without Time Zone-----:"+xmlDate.toString());
27 
28             //To Remove Time information
29             xmlDate.setTime(DatatypeConstants.FIELD_UNDEFINED,
30                     DatatypeConstants.FIELD_UNDEFINED,
31                     DatatypeConstants.FIELD_UNDEFINED,
32                     DatatypeConstants.FIELD_UNDEFINED);
33             System.out.println("Without Time Zone & Time :- " + xmlDate.toString());
34 
35         } catch (DatatypeConfigurationException e) {
36             e.printStackTrace();
37         }
38     }
39 
40 
41 }

 

转载于:https://www.cnblogs.com/javallh/p/9450107.html

您可能感兴趣的与本文相关的镜像

Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

The `tar` command is used for archiving files and directories in Unix-like systems. When using `tar` to extract an archive, the `--strip-components` option can be used to remove the leading part of the member names. ### Explanation The `--strip-components` option followed by a number `N` tells `tar` to remove the first `N` leading pathname components from each file being extracted. This is useful when you have an archive where the files are nested inside a directory structure, and you want to extract them directly to the current directory without creating the full nested structure. ### Usage Here are some examples: #### Example 1: Extracting files without the top-level directory Suppose you have an archive named `archive.tar` with the following structure inside: ``` archive/ ├── file1.txt ├── file2.txt └── subdir/ └── file3.txt ``` If you want to extract the files directly to the current directory without creating the `archive` directory, you can use the following command: ```bash tar -xvf archive.tar --strip-components=1 ``` In this case, `--strip-components=1` removes the first path component (`archive`), and the files will be extracted directly to the current directory. #### Example 2: Extracting files from a deeper directory structure If the archive has a deeper structure like this: ``` parent/ ├── child/ │ ├── file1.txt │ └── file2.txt └── subdir/ └── file3.txt ``` And you want to extract the files from the `child` directory directly to the current directory, you can use: ```bash tar -xvf archive.tar --strip-components=2 ``` Here, `--strip-components=2` removes the first two path components (`parent` and `child`). ### Summary The `--strip-components` option of the `tar` command is a powerful tool for customizing the extraction process and controlling the directory structure of the extracted files.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值