ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Tips To Do JAVA STRING TO DATE Conversion Like A PRO

Автор: Begin Secure

Загружено: 2022-03-29

Просмотров: 239

Описание: Learn how to do Java String to Date conversion. What to watch out for in the old Java libraries. They can cause really hard to find bugs in your code, not to mention cause security issues in your code. Tune in to find out!!

Come back often for more videos answering common questions around development and application security.

#IT #Development #SoftwareDevelopment #JavaProgramming #JavaTutorial #AppplicationSecurity #AppSec #appsecurity #informationsecurity #infosec

Chapters

00:00 Introduction
00:39 Overview
01:33 Understand Date/Time Format
05:38 Code the solution
12:46 Discuss security aspects

So the question we address in this video is: how can we do a String to date conversion in java?

Let’s say that we have a String like the following:

We assign the string variable myDate equal to the String January first, 2020 with the month January written out in text format.

And let’s say we want to parse that string to read the month, the day and the year. How can we do that?

In contemporary Java, we can make use of the class java.time.format.DateTimeFormatter

In order to read the string January 1, 2020, we would need to create a pattern that represents the
data that we will be parsing

In our example of January 1st, 2020, we can represent that pattern like we see here with 4 M’s

Followed by a d, followed by a comma and 4y’s

Let’s look at each of those symbols in our pattern to see what they mean and how the data will be interpreted. First, is the M for month.

4 M’s means the month of the year

The number of M’s determines how the pattern is expected to look.

Less than 4 characters (less than 4 M’s) will mean our formatter class will expect the shortened form of the month name, for example, “Jan” for “January”

Exactly 4 M characters will mean that we expect the full form of the data and the month name spelled out completely

Exactly 5 M characters will mean that we expect the narrow form of the month. We will see what that means when we get into the coding section of this video

Continuing with our breakdown of the pattern, next, let’s look at the d.

The symbol d indicates that the string should contain the day of the month.

It is a lower case d

A single lower case d is fine for eithter 1 or 2 digit days in a string, so either January one or January 25 for example will both work eaqually well when only one d is specified.

If the string uses 2 dees, it will work for double digit days of the month, like 25, but will fail with a parse exception for single digit days, like 1.

If an upper case D is used, it represent the day of the year, so a number between 1 and 365 or 366 for leap year.

Next in our list of symbols used to parse our original string, is the lower case y.

The lower case y symbol represents the year of the era

The number of y’s should match the number of digits in the year.

For example 4 y’s will represent a 4 digit year and 2 y’s will represent a 2 digit year

An upper case Y is used to parse for a week based year,
ensuring the year has has whole weeks that can span into the next year.

This is a bit of an unusual circumstance that might be used for fiscal years for example in an accounting or government application.

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Tips To Do JAVA STRING TO DATE Conversion Like A PRO

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Why Is Processing A SORTED ARRAY IN JAVA Faster Than Processing An Unsorted Array In Java?

Why Is Processing A SORTED ARRAY IN JAVA Faster Than Processing An Unsorted Array In Java?

Learn DATES & TIMES with Java in 8 minutes! 📆

Learn DATES & TIMES with Java in 8 minutes! 📆

ООП На Простых Примерах | Объектно-Ориентированное Программирование

ООП На Простых Примерах | Объектно-Ориентированное Программирование

Основы ПЛК: релейная логика

Основы ПЛК: релейная логика

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

Kubernetes — Простым Языком на Понятном Примере

Kubernetes — Простым Языком на Понятном Примере

Строки Java неизменяемы — вот что это на самом деле означает

Строки Java неизменяемы — вот что это на самом деле означает

Крах Jaguar: Как “повестка” в рекламе добила легенду британского автопрома

Крах Jaguar: Как “повестка” в рекламе добила легенду британского автопрома

4 часа Шопена для обучения, концентрации и релаксации

4 часа Шопена для обучения, концентрации и релаксации

Трамп сорвал переговоры / Авиация поднята по тревоге

Трамп сорвал переговоры / Авиация поднята по тревоге

Лучший Гайд по Kafka для Начинающих За 1 Час

Лучший Гайд по Kafka для Начинающих За 1 Час

Но что такое нейронная сеть? | Глава 1. Глубокое обучение

Но что такое нейронная сеть? | Глава 1. Глубокое обучение

Use JAVA COMPARE STRINGS Techniques The Right Way

Use JAVA COMPARE STRINGS Techniques The Right Way

Что такое

Что такое "Reverse Engineering". Показываю как ломают софт.

Алгоритмы и структуры данных за 15 минут! Вместо 4 лет универа

Алгоритмы и структуры данных за 15 минут! Вместо 4 лет универа

Алгоритмы на Python 3. Лекция №1

Алгоритмы на Python 3. Лекция №1

Как производятся микрочипы? 🖥️🛠️ Этапы производства процессоров

Как производятся микрочипы? 🖥️🛠️ Этапы производства процессоров

Учебник по Excel за 15 минут

Учебник по Excel за 15 минут

Изучите Java за 14 минут (серьезно)

Изучите Java за 14 минут (серьезно)

#95 Comparator vs Comparable in Java

#95 Comparator vs Comparable in Java

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]