Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AlexanderJonsson/Swatch-Internet-Time
A very simple library for getting the current time as .beats "Swatch internet time"
https://github.com/AlexanderJonsson/Swatch-Internet-Time
beats futurism internet-time swatch time timekeeping timezones timing
Last synced: about 2 months ago
JSON representation
A very simple library for getting the current time as .beats "Swatch internet time"
- Host: GitHub
- URL: https://github.com/AlexanderJonsson/Swatch-Internet-Time
- Owner: AlexanderJonsson
- Created: 2023-03-19T12:53:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-04-08T20:47:33.000Z (about 1 year ago)
- Last Synced: 2024-02-04T06:11:20.401Z (5 months ago)
- Topics: beats, futurism, internet-time, swatch, time, timekeeping, timezones, timing
- Language: Java
- Homepage: http://www.alexanderjonsson.se/defending-the-indefensible-d3095746
- Size: 93.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Lists
- awesome-internettime - Swatch-Internet-Time
README
# Swatch Internet Time Java Library
(README.md generated by ChatGPT)This Java library provides a simple way to get the current time in Swatch Internet Time beats. Swatch Internet Time is a decimal time concept introduced by the Swatch Group in 1998, which divides the 24-hour day into 1,000 "beats", each beat lasting 1 minute and 26.4 seconds.
## Usage
To use the `InternetTime` class, first import it into your Java project:
```java
import se.alexanderjonsson.InternetTime;
```
Then, you can call one of the following static methods to get the current Swatch Internet Time:
```java
// Returns the current time as an Integer
int swatchTimeInt = InternetTime.getCurrentTimeAsInteger();// Returns the current time as a Double with two decimal places
double swatchTimeDouble = InternetTime.getCurrentTimeAsDouble();// Returns the current time as a formatted String
String swatchTimeStringWithDecimals = InternetTime.getCurrentTimeAsString(TimeFormat.WITH_DECIMALS); // e.g. "123.23"
String swatchTimeStringWithoutDecimals = InternetTime.getCurrentTimeAsString(TimeFormat.WITHOUT_DECIMALS); // e.g. "123"// Returns a String representation of the current Swatch Internet Time in the format "@.beats"
String swatchTimeString = InternetTime.toString(); // e.g. "@009.23.beats"
```
Note that the getCurrentTimeAsString() method both allow you to specify a TimeFormat enum value to control the formatting of the returned value. The TimeFormat enum has four values: WITH_CENTIBEATS, WITHOUT_CENTIBEATS, CENTIBEATS_WITHOUT_LEADING_ZEROES, WITHOUT_CENTIBEATS_WITHOUT_LEADING_ZEROES. If you don't specify a TimeFormat, the default is WITH_CENTIBEATS.
```java
public enum TimeFormat {
WITH_CENTIBEATS,
WITHOUT_CENTIBEATS,
CENTIBEATS_WITHOUT_LEADING_ZEROES,
WITHOUT_CENTIBEATS_WITHOUT_LEADING_ZEROES;
}
```